Hello,everybody.
I recorded script using Grinder 3.0 TCPProxy before I tried to test a portal web performance in my localhost.The following is part of the recorded script.
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPPluginControl, HTTPRequest
from HTTPClient import NVPair
connectionDefaults = HTTPPluginControl.getConnectionDefaults()
httpUtilities = HTTPPluginControl.getHTTPUtilities()
{/* omit lines of recorded script * /}
headers10= \
( NVPair('Accept', '*/*'),
NVPair('Referer', 'http://localhost:8080/c/portal/home'), )
{/* omit lines of recorded script * /}
request100 = HTTPRequest(url=url0, headers=headers10)
request100 = Test(100, 'GET javascript_cached').wrap(request100)
{/* omit lines of recorded script * /}
def page12(self):
"""GET javascript_cached (request 102)."""
self.token_languageId = \
'en_US'
result = request100.GET('/c/portal/javascript_cached' +
'?themeId=' +
self.token_themeId +
'&languageId=' +
self.token_languageId +
'&colorSchemeId=' +
self.token_colorSchemeId, None,
( NVPair('If-Modified-Since', 'Wed, 31 Jan 2007 03:00:39 GMT'), ))
return result
{/* omit lines of recorded script * /}
I Added two function definitions to modify the script so as to use it as a test script.The two function definitions are printed out as below:
(a) def page80(self):
''''''GET response(request 100).''''''
result=request100.GET('http://localhost:8080/c/portal/home')
writeToFile(result.getText(),HttpResponse)
return result
(b)
#write the response
def writeToFile(text,testid):
filename=grinder.getFilenameFactory().createFilename(testid+"data.txt")
file=open(filename,"w")
print >> file,text
file.close()
The purpose of these two functions is to record the response content of request100 in a testing.however,it can not record the response.I have read book <<j2ee performance testing>> and also search the answer in many place ,but I have not gotten the answer.and I have the following question that I want to ask:
(1) what content will be responsed after executing request100.GET('http://localhost:8080/c/portal/home'),and what is the data type of response.
(2) How can create the file and record the response content in it
(3) Where can I find the Library Reference for HTTPRequest( ) etc.
Please reply your experience or tips to help me to solve it. Thanks you.