【问题标题】:Is it possible to run code after finishing a locust instance?完成蝗虫实例后是否可以运行代码?
【发布时间】:2021-12-18 07:32:29
【问题描述】:

假设这是我将在终端运行的主要文件,即locusts -f main.py。在 locust 实例终止或达到时间限制后,是否可以让它也运行代码?可能是清理脚本或将生成的 csv 报告发送到某处。

class setup(HttpUser):
     wait_time = between(3, 5)
     host = 'www.example.com'
     tasks = [a, b, c...]

#do something after time limit reached

【问题讨论】:

  • 我们不能指定测试开始和结束的事件吗?

标签: python locust


【解决方案1】:

有一个 test_stop 事件 (https://docs.locust.io/en/stable/extending-locust.html) 和一个 quitting 事件 (https://docs.locust.io/en/stable/api.html#locust.event.Events.quitting) 可以用于此目的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-13
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 2013-06-02
    • 1970-01-01
    • 1970-01-01
    • 2022-12-05
    相关资源
    最近更新 更多