FunkLoad安装使用(二):基础使用篇

* setUpCycle hook: ... done.
* Current time: 2017-04-23T20:12:27.993818
* Starting threads: .......... done.
* Logging for 10s (until 2017-04-23T20:12:38.140282):  done.
* Waiting end of threads: .................... done.
* Waiting cycle sleeptime 1s: ... done.
* tearDownCycle hook: ... done.
* End of cycle, 66.10s elapsed.
* Cycle result: **SUCCESSFUL**, 0 success, 0 failure, 0 errors.

Cycle #2 with 20 virtual users
------------------------------

* setUpCycle hook: ... done.
* Current time: 2017-04-23T20:13:34.098219
* Starting threads: .................... done.
* Logging for 10s (until 2017-04-23T20:13:44.371939):  done.
* Waiting end of threads: ........................................ done.
* Waiting cycle sleeptime 1s: ... done.
* tearDownCycle hook: ... done.
* End of cycle, 118.90s elapsed.
* Cycle result: **SUCCESSFUL**, 0 success, 0 failure, 0 errors.

* tearDownBench hook: ... done.

Result
======

* Success: 0
* Failures: 0
* Errors: 0

Bench status: **SUCCESSFUL**

5、生成报表
XML结果文件可以转换为HTML报告:
root@ubuntu:/home/ruink/funkload-demo/simple# fl-build-report --html simple-bench.xml
Creating html report: .../home/ruink/funkload-demo/simple/test_simple-20170423T201132/index.rst:101: (WARNING/2) Inline literal start-string without end-string.
/home/ruink/funkload-demo/simple/test_simple-20170423T201132/index.rst:101: (WARNING/2) Inline literal start-string without end-string.
done: 
/home/ruink/funkload-demo/simple/test_simple-20170423T201132/index.html
它应该产生这样的东西:
http://funkload.nuxeo.org/report-example/test_simple-20110126T232251/
请注意,我们的简单基准测试中没有监控。

Funkload报告

6、写你自己的测试
编写新测试的过程如下:
1、使用录制器初始化测试用例和配置文件并抓取请求。
2、在Firefox中进行测试并显示每个响应,这将帮助你添加断言并检查响应:
fl-run-test -dV test_BasicNavigation.py
3、实施动态部分:
对于每个请求,添加断言以确保页面是你期望的页面。这可以通过检查一个术语是否存在于响应中来完成:
self.assert_('logout' in self.getBody(), "Login failure")
要生成随机输入,可以使用FunkLoad.Lipsum模块:
from funkload import Lipsum
...
lipsum = Lipsum()
# Get a random title
title = lipsum.getSubject()
从先前的响应中提取令牌:
from funkload.utils import extract_token
...
jsf_state = extract_token(self.getBody(), ' id="javax.faces.ViewState" value="', '"')
要使用凭证服务器,如果你想用不同的用户做一个工作台,或根本不想硬编码你的登录/密码:
from funkload.utils import xmlrpc_get_credential
...
# get an admin user
login, pwd = xmlrpc_get_credential(host, port, "admin")
使用Makefile配置monitoring并自动执行基准测试。

上一页12下一页


留言