Lately I have been using The Grinder to simulate some http user traffic. Its a great little free tool. Here are a few tips to help you with correlating data from server responses.
Firstly, make sure that you can interrogate data for your server responses if they are compessed responses, you will need to decompress them. Keep in mind this will have an impact on your performance.
At the top of your script place these 2 lines
connectionDefaults.useTransferEncoding = 1 connectionDefaults.useContentEncoding = 1
Now to assist with your debugging create an instance of the log output to allow dumping of server responses to the normal output logs. This will assist with interrogating the server response for correlation purposes. Here is code snippet
log = grinder.logger.output """GET / (request 101).""" result = request101.GET('/') log(result.getText())
Finally to simplify your correlation you can use this little function which I enhanced from Ainars Galvans. By the way to find out what to correlate using the standard process of recording 2 scripts, following the exact same process and then executing a diff on the 2 outputs. This is a good starting point. Anyhow heres the little correlation function and an example of its use.
class TestRunner: """A TestRunner instance is created for each worker thread.""" # A method for each recorded page. def page1(self): """GET / (request 101).""" result = request101.GET('/') log(result.getText()) self.jsessionid = findVar(result.getText(), 'jsessionid', '"') return result def page2(self): """GET blank.gif (request 201).""" self.token_jsessionid = \ self.jsessionid result = request201.GET('/wm_cafshared/ui/img/blank.gif;jsessionid=' + self.token_jsessionid) def findVar(text, searchstring, endchar): #Calculating at which character the substring begins startCutPos = text.find(searchstring) + len(searchstring) #Now scanning characters one-by-one until encounter the End character. x = 0 while (text[startCutPos + x] <> endchar): x=x+1 endCutPos = startCutPos + x #Now it’s time to cut the substring subString = text[startCutPos:endCutPos] # this line for debug print 'jsessionid: ' + subString return subString
Correlate to your hearts content.