Sometimes clients send me VuGen scripts that they can’t get working. It can be difficult to help them when I don’t have access to their application and so can’t run their script myself. Trying to figure out what is happening by looking at the VuGen recording and replay logs is not much fun.
One day I realised that the VuGen recording snapshots contained a complete record of every HTTP request and response that was sent when the script was recorded, and that I could re-create the recorded website by doing some smart things with a local web server and my hosts file. After using it myself for a while, I have released the tool I created so that other performance testers can use it too.
The VuGen Local Replay tool helps script developers to:
- Replay a web-based VuGen script even if you don’t have access to the application
- Use the recorded application in a web browser, and click through the same steps that were recorded in the VuGen script
Please note: there is a critical bug in the tool right now, so please delay your download unless you want to help debug it. :)
- Download and install WampServer. This will set up an Apache web server, PHP 5 and MySQL on your Windows system.
- Download VuGenLocalReplay, unzip it, and copy the files in the www folder to C:\wamp\www.
- Copy a VuGen script (that still has its recording snapshots and log) to C:\wamp\www\vugen.
- Open your web browser and navigate to http://localhost/ and follow the prompts to modify your Windows hosts file and Apache configuration.
- Cut and paste the first URL from your VuGen recording into your web browser, and click through the steps of your business process. If the steps work manually, then you should now be able to replay your VuGen script on your local PC.
How it works
When a VuGen script is recorded, all the HTTP requests and responses (including HTTP headers) are saved in the script’s /data folder. This information is used during the script generation step (when the HTTP capture data is translated into C function calls), and for the display of “recording snapshots” in VuGen.
The function calls in the generated script contain references to their corresponding snapshot file e.g. t1.inf.
web_url("Example", "URL=http://www.example.com", "Resource=0", "Referer=", "Snapshot=t1.inf", // <-- snapshot file "Mode=HTML", EXTRARES, "URL=favicon.ico", ENDITEM, LAST);
The inf files reference a snapshot.xml file which contains every HTTP request header (and request body if it is a POST), and every HTTP response header. The response body data is stored in a file that is referenced from the inf file. The example inf file below shows the HTML page stored in t1.htm and the favicon.ico file stored in t1_favicon.html.
[t1] FileName1=t1.htm URL1=http://www.example.com Total=12 RequestHeaderFile=t1_RequestHeader.txt RequestBodyFile=NONE ResponseHeaderFile=t1_ResponseHeader.txt ContentType=text/html SnapshotXmlFile=snapshot_1.xml FileName2=t1_favicon.html URL2=http://www.example.com/favicon.ico
The Windows hosts file must be modified so that any requests to the website are sent to 127.0.0.1. A local Apache web server instance receives the requests. The mod_rewrite module ensures that all requested URLs are actually served by a single PHP page. The PHP code looks up the HTTP request to find the matching response in the snapshot data. The HTTP response headers and body will be the same as those seen during recording.
How to contribute
You can help make this tool better. If you have found a bug, or have a question, please create an issue in the VuGenLocalReplay GitHub project (you will need to create a GitHub account first). If you think you can improve my PHP code, then please create an issue describing your change, then send me a pull request.
I have spent a lot of personal time developing the VuGen Local Replay tool, and I am giving it away for free. You can say thank you by linking to this page from your website, mentioning it on Twitter, and telling other performance testers about it.