我使用TCPProxy控制台创建了jython测试用例脚本。但那些不起作用,而我正试图跑。
我的测试用例是
Sample33.py
# The Grinder 3.11
# HTTP script recorded by TCPProxy at 29 Jul, 2014 10:19:35 AM
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()
# To use a proxy server, uncomment the next line and set the host and port.
# connectionDefaults.setProxyServer("localhost", 8001)
def createRequest(test, url, headers=None):
"""Create an instrumented HTTPRequest."""
request = HTTPRequest(url=url)
if headers: request.headers=headers
test.record(request, HTTPRequest.getHttpMethodFilter())
return request
# These definitions at the top level of the file are evaluated once,
# when the worker process is started.
connectionDefaults.defaultHeaders = \
[ NVPair('Accept-Encoding', 'gzip, deflate'),
NVPair('Accept-Language', 'en-US,en;q=0.5'),
NVPair('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0'), ]
headers0= \
[ NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
NVPair('Referer', 'http://mycompany.com/'), ]
url0 = 'http://mycompany.com:80'
request101 = createRequest(Test(101, 'GET /'), url0)
request201 = createRequest(Test(201, 'POST home'), url0, headers0)
request202 = createRequest(Test(202, 'GET home'), url0, headers0)
request203 = createRequest(Test(203, 'GET /'), url0, headers0)
request301 = createRequest(Test(301, 'GET holidays-2014'), url0, headers0)
request302 = createRequest(Test(302, 'GET Untitled_3.png'), url0)
request303 = createRequest(Test(303, 'GET Untitled_3.png'), url0)
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('/', None,
( NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
NVPair('If-Modified-Since', 'Mon, 28 Jul 2014 10:47:07 +0000'),
NVPair('If-None-Match', '\"1406544427\"'), ))
self.token_form_build_id = \
httpUtilities.valueFromHiddenInput('form_build_id') # 'form-MvE2-tuZ5-faR4EyZ0XSU6qaOpz8rex1-4u...'
self.token_form_id = \
httpUtilities.valueFromHiddenInput('form_id') # 'user_login_block'
return result
def page2(self):
"""POST home (requests 201-203)."""
self.token_destination = \
'node/103'
# Expecting 302 'Found'
result = request201.POST('/home' +
'?destination=' +
self.token_destination,
( NVPair('name', 'myuser'),
NVPair('pass', 'mypassword'),
NVPair('form_build_id', self.token_form_build_id),
NVPair('form_id', self.token_form_id),
NVPair('op', 'Log in'), ),
( NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))
grinder.sleep(27)
# Expecting 301 'Moved Permanently'
request202.GET('/home')
grinder.sleep(18)
request203.GET('/', None,
( NVPair('If-Modified-Since', 'Tue, 29 Jul 2014 04:47:09 +0000'),
NVPair('If-None-Match', '\"1406609229\"'), ))
return result
def page3(self):
"""GET holidays-2014 (requests 301-303)."""
result = request301.GET('/content/holidays-2014')
self.token_form_build_id = \
httpUtilities.valueFromHiddenInput('form_build_id') # 'form-VWPMyhphM5Lg3O6qyQx1iS_uc6p20Scw7cY...'
self.token_form_token = \
httpUtilities.valueFromHiddenInput('form_token') # 'DT9Ya9GCdGKlSNIEMLP4noRGMnd4Dvs2WVgMsEsw...'
self.token_form_id = \
httpUtilities.valueFromHiddenInput('form_id') # 'search_block_form'
grinder.sleep(47)
request302.GET('/sites/default/files/Untitled_3.png', None,
( NVPair('Accept', 'image/png,image/*;q=0.8,*/*;q=0.5'),
NVPair('Referer', 'http://mycompany.com/content/holidays-2014'), ))
return result
def __call__(self):
"""Called for every run performed by the worker thread."""
self.page1() # GET / (request 101)
grinder.sleep(279)
self.page2() # POST home (requests 201-203)
grinder.sleep(147)
self.page3() # GET holidays-2014 (requests 301-303)
# Instrument page methods.
Test(100, 'Page 1').record(TestRunner.page1)
Test(200, 'Page 2').record(TestRunner.page2)
Test(300, 'Page 3').record(TestRunner.page3)
我的属性文件:test.properties
grinder.script=sample33.py
grinder.processes=1
grinder.threads=1
grinder.runs=0
grinder.logDirectory=log
grinder.numberOfOldLogs=2
grinder.useConsole=false
2014-07-29 11:01:10,579 INFO myuser-0 thread-0 [ run-193, test-301 ]: http://mycompany.com/content/holidays-2014 -> 403 Forbidden, 18674 bytes
2014-07-29 11:01:10,579 INFO myuser-0 thread-0 [ run-193 ]: sleeping for 48 ms
2014-07-29 11:01:10,652 INFO myuser-0 thread-0 [ run-193, test-302 ]: http://mycompany.com/sites/default/files/Untitled_3.png -> 200 OK, 130429 bytes
2014-07-29 11:01:10,996 INFO myuser-0 thread-0 [ run-194, test-101 ]: http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:10,997 INFO myuser-0 thread-0 [ run-194 ]: sleeping for 263 ms
2014-07-29 11:01:11,686 INFO myuser-0 thread-0 [ run-194, test-201 ]: http://mycompany.com/home?destination=node/103 -> 302 Found, 0 bytes [Redirect, ensure the next URL is http://mycompany.com/home]
2014-07-29 11:01:11,686 INFO myuser-0 thread-0 [ run-194 ]: sleeping for 27 ms
2014-07-29 11:01:11,973 INFO myuser-0 thread-0 [ run-194, test-202 ]: http://mycompany.com/home -> 301 Moved Permanently, 0 bytes [Redirect, ensure the next URL is http://mycompany.com/]
2014-07-29 11:01:11,973 INFO myuser-0 thread-0 [ run-194 ]: sleeping for 17 ms
2014-07-29 11:01:12,229 INFO myuser-0 thread-0 [ run-194, test-203 ]: http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:12,229 INFO myuser-0 thread-0 [ run-194 ]: sleeping for 141 ms
2014-07-29 11:01:12,681 INFO myuser-0 thread-0 [ run-194, test-301 ]: http://mycompany.com/content/holidays-2014 -> 403 Forbidden, 18674 bytes
2014-07-29 11:01:12,682 INFO myuser-0 thread-0 [ run-194 ]: sleeping for 46 ms
2014-07-29 11:01:12,751 INFO myuser-0 thread-0 [ run-194, test-302 ]: http://mycompany.com/sites/default/files/Untitled_3.png -> 200 OK, 130429 bytes
2014-07-29 11:01:13,033 INFO myuser-0 thread-0 [ run-195, test-101 ]: http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:13,034 INFO myuser-0 thread-0 [ run-195 ]: sleeping for 307 ms
2014-07-29 11:01:13,937 INFO myuser-0 thread-0 [ run-195, test-201 ]: http://mycompany.com/home?destination=node/103 -> 302 Found, 0 bytes [Redirect, ensure the next URL is http://mycompany.com/home]
2014-07-29 11:01:13,938 INFO myuser-0 thread-0 [ run-195 ]: sleeping for 27 ms
2014-07-29 11:01:14,223 INFO myuser-0 thread-0 [ run-195, test-202 ]: http://mycompany.com/home -> 301 Moved Permanently, 0 bytes [Redirect, ensure the next URL is http://mycompany.com/]
2014-07-29 11:01:14,224 INFO myuser-0 thread-0 [ run-195 ]: sleeping for 18 ms
2014-07-29 11:01:14,480 INFO myuser-0 thread-0 [ run-195, test-203 ]: http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:14,480 INFO myuser-0 thread-0 [ run-195 ]: sleeping for 149 ms
2014-07-29 11:01:14,931 INFO myuser-0 thread-0 [ run-195, test-301 ]: http://mycompany.com/content/holidays-2014 -> 403 Forbidden, 18674 bytes
2014-07-29 11:01:14,932 INFO myuser-0 thread-0 [ run-195 ]: sleeping for 49 ms
2014-07-29 11:01:15,003 INFO myuser-0 thread-0 [ run-195, test-302 ]: http://mycompany.com/sites/default/files/Untitled_3.png -> 200 OK, 130429 bytes
2014-07-29 11:01:15,277 INFO myuser-0 thread-0 [ run-196, test-101 ]: http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:15,278 INFO myuser-0 thread-0 [ run-196 ]: sleeping for 301 ms
2014-07-29 11:01:15,332 INFO myuser-0 : communication shut down
2014-07-29 11:01:15,340 INFO myuser-0 thread-0 [ run-196 ]: shut down
2014-07-29 11:01:15,341 INFO myuser-0 thread-0: finished 196 runs
2014-07-29 11:01:15,341 INFO myuser-0 : elapsed time is 404648 ms
2014-07-29 11:01:15,341 INFO myuser-0 : Final statistics for this process:
2014-07-29 11:01:15,350 INFO myuser-0 :
Tests Errors Mean Test Test Time TPS Mean Response Response Mean time to Mean time to Mean time to
Time (ms) Standard response bytes per errors resolve host establish first byte
Deviation length second connection
(ms)
(Test 100 197 0 286.38 35.05 0.49 0.00 0.00 0 - - 0.00) "Page 1"
Test 101 197 0 285.10 34.57 0.49 17617.00 8576.71 197 0.10 2.25 265.98 "GET /"
(Test 200 196 0 970.07 233.03 0.48 0.00 0.00 0 - - 0.00) "Page 2"
Test 201 196 0 453.68 223.42 0.48 0.00 0.00 0 0.03 2.51 453.05 "POST home"
Test 202 196 0 219.01 30.85 0.48 0.00 0.00 0 0.02 2.26 218.58 "GET home"
Test 203 196 0 250.14 22.02 0.48 17617.00 8533.17 196 0.02 2.20 230.47 "GET /"
(Test 300 196 0 379.49 33.35 0.48 0.00 0.00 0 - - 0.00) "Page 3"
Test 301 196 0 302.42 32.69 0.48 18674.00 9045.16 196 0.01 2.20 283.80 "GET holidays-2014"
Test 302 196 0 28.66 4.78 0.48 130429.00 63176.10 0 0.01 2.19 6.21 "GET Untitled_3.png"
Totals 1177 0 256.53 157.42 2.91 30711.70 89331.14 589 0.03 2.27 243.03
(589) (0)
Tests resulting in error only contribute to the Errors column.
Statistics for individual tests can be found in the data file, including
(possibly incomplete) statistics for erroneous tests. Composite tests
are marked with () and not included in the totals.
它显示的所有页面仅403错误。 我也试过录音(保存每一页)。只有登录页面才能录制(保存)其他页面。不来了 请帮助我,是否需要更改自动生成的代码中的任何内容?
什么是'name'和'pass'字段,是否对每个网址都是稳定的,否则我必须更改与我的网站相对应的内容?
答案 0 :(得分:0)
请参阅此链接Error 403
我相信你必须去和你的服务器/网络团队谈谈。这是本地网络问题,而不是研磨器。
您可以尝试不使用DNS进行录制,因为它位于ipaddress中的网络类型中,然后记录您的交互或将URL更改为IP地址。
但是,如果切换到ip,请记住,您将无法获得负载平衡的好处。