bin*_*thb 17 python load-testing locust
官方locustio文档讲述了如何编写无限运行的简单蝗虫任务.
无法找到如何运行持续特定时间的负载,以便测试将在指定的时间间隔后自动停止.
我不需要它从Web界面,命令行/代码选项将是伟大的.
小智 21
我最近开始自己使用蝗虫,不幸的是,蝗虫0.7.1没有提供基于一段时间终止测试的方法.
但它确实提供了一种根据已发出的请求数终止测试的方法.如果使用CLI界面运行locust,则可以指定在处理完指定数量的请求后停止执行.从locust --help输出:
-n NUM_REQUESTS, --num-request=NUM_REQUESTS
Number of requests to perform. Only used together with --no-web
Run Code Online (Sandbox Code Playgroud)
因此,您可以使用以下内容开始会话:
# locust --clients=20 --hatch-rate=2 --num-request=500
Run Code Online (Sandbox Code Playgroud)
并且一旦处理了500个请求,它应该终止测试.
参加聚会的时间很晚,但是我偶然发现停止测试,这可能有所帮助。
stop_timeout = 20
Run Code Online (Sandbox Code Playgroud)
在你的蝗虫课上。
哦,它接受秒的值。
回答可能为时已晚,但将来可能对某人有所帮助。现在,使用--no-web选项运行Locust时,Locust 支持-t或--run-time选项来指定持续时间。来自locust --help:
-t RUN_TIME, --run-time=RUN_TIME
Stop after the specified amount of time, e.g. (300s,
20m, 3h, 1h30m, etc.). Only used together with --no-
web
Run Code Online (Sandbox Code Playgroud)
可以通过抛出StopLocust异常来停止单个greenlet("locust"),这样你就可以在Task中添加一个检查时间来检查时间
这是未记录的行为,将来可能会改变,但它在0.7.2中有效!
http://lookonmyworks.co.uk/2015/03/13/stopping-a-locust/
| 归档时间: |
|
| 查看次数: |
10544 次 |
| 最近记录: |