Testing a new web server w/o fiddling w/DNS
02 Feb 2012At $WORK I'm slowly migrating our website to a new server. I came up with a Small but Useful(tm) program called Thornhill to help; it looks at Apache Alias directives, then queries both the old and the new server to make sure the results are the same. Since the new server doesn't have DNS pointed at it yet, this requires some trickery.
I'm using Perl's WWW::Mechanize module to do this, and after some
thought I figured I could just add a new Host: oldhost.example.org
header to the request. And that works; even though the request is going
to the new host, it's still asking for the URL of the website. IOW,
it's querying it as though it were live. And lo, my tests came back
mostly passing, and there was much rejoicing.
Except that I noticed I was getting redirects for some things. Which
makes sense -- /java_app
should probably go to /java_app
/, and
then to /java_app/home.html?jsessionid=666
. But those go to the
current, live site:
- Request goes to test site:
http://newhost.example.org/java_app
, but withHost: oldhost.example.org
- New site redirects to
http://oldhost.example.org/java_app/
- Script follows the redirect and sends the request directly to oldhost...the production one that I already know is working.
So basically Thornhill works up until the point where it gets redirected. ARGHH.
In theory I can override this in the module, but this turns out to be surprisingly difficult. And WWW::Mechanize has a TODO list a mile long, including an option to not follow redirects. And I ran into the same dang bug I ran into five years ago.
I'm trying Python now. But I'm starting to wonder if I should just abandon this approach and fiddle with the /etc/hosts file or something. This is getting...tedious? finicky? ridiculous? Something.
UPDATE: Python Requests is the bomb.
Add a comment:
Name and email required; email is not displayed.
Related Posts
QRP weekend 08 Oct 2018
Open Source Cubesat Workshop 2018 03 Oct 2018
mpd crash? try removing files in /var/lib/mpd/ 11 Aug 2018