【发布时间】:2013-01-26 17:19:19
【问题描述】:
我正在使用 multi-mechanize 和 urllib2 在网络服务器上运行示例
#!/usr/bin/env python
import urllib2
import time
import random
class Transaction(object):
def __init__(self):
pass
def run(self):
start_timer = time.time()
resp = urllib2.urlopen('http://192.168.16.114/1.html')
content = resp.read()
latency = time.time() - start_timer
self.custom_timers['Example_Homepage'] = latency
assert (resp.code == 200), 'Bad Response: HTTP %s' % resp.code
assert ('Example Web Page' in content), 'Text Assertion Failed'
if __name__ == '__main__':
trans = Transaction()
trans.run()
print trans.custom_timers
运行项目后,我可以看到每个交易的错误,但不确定是什么错误,因为我可以看到网络服务器正确响应请求,有人可以建议吗?
[root@dev1-proxy3 scripts]# multimech-run k1_testrun
user_groups: 2
threads: 6
[================100%==================] 30s/30s transactions: 23879 timers: 23879 errors: 23879
analyzing results...
transactions: 23888
errors: 23888
test start: 2013-01-26 12:59:23
test finish: 2013-01-26 12:59:53
created: ./k1_testrun/results/results_2013.01.26_12.59.23/results.html
done.
【问题讨论】:
-
您可能需要将 self.custom_timers 初始化为 {}
-
做到了,但仍然报错
-
先不用多机直接运行
-
您确定网页@192.168.16.114/1.html 包含确切的文本“示例网页”吗?在 config.cfg 中打开 console logging = on 可能会产生有趣的结果。结果 csv 文件显示什么?
标签: python linux performance performance-testing