Locust 如何使用 docker-compose 并获得聚合结果

locust how to use docker-compose and get aggregated results

我正在使用 Locust 进行 运行 负载测试。具体来说,我正在尝试使用 docker-compose 并遵循 https://docs.locust.io/en/stable/running-locust-docker.html

上的文档

我想按照 https://docs.locust.io/en/stable/retrieving-stats.html 中的说明以 CSV 格式检索测试统计数据 现在,当 运行 设置此设置时 headless 我怎样才能从所有工作人员那里获得 CSV 格式的汇总结果?非无头版本允许我将汇总的结果下载为 CSV,但我不确定无头版本是否适用于此处。 谢谢!

你应该只需要担心 运行 --headless --csv=example(正如你链接到的文档页面所指出的那样)等等。工人不需要这些,因为 headless 只适用于主人,他们不会汇总自己的结果。 master 生成的 CSV 应该包含所有 worker 的所有结果。如果您尝试过此操作但没有看到所需的所有数据,您可能想尝试添加 --csv-full-history.

来自文档页面:

The files will be named example_stats.csv, example_failures.csv and example_history.csv (when using --csv=example). The first two files will contain the stats and failures for the whole test run, with a row for every stats entry (URL endpoint) and an aggregated row. The example_history.csv will get new rows with the current (10 seconds sliding window) stats appended during the whole test run. By default only the Aggregate row is appended regularly to the history stats, but if Locust is started with the --csv-full-history flag, a row for each stats entry (and the Aggregate) is appended every time the stats are written (once every 2 seconds by default).