node.js - Artillery.io:如何为每个场景生成测试报告?
问题描述
Artillery:如何按顺序运行场景并将每个场景的结果显示在同一个文件中?
我目前正在编写 nodejs 测试artillery.io
来比较我实现的两个端点之间的性能。我定义了两个场景,我想在同一个报告文件中获得每个场景的结果。测试的执行不是顺序的,这意味着在测试结束时我已经组合了一个结果,不可能知道每个测试的性能,但只能知道所有测试的性能。
config:
target: "http://localhost:8080/api/v1"
plugins:
expect: {}
metrics-by-endpoint: {}
phases:
- duration: 60
arrivalRate: 2
environments:
dev:
target: "https://backend.com/api/v1"
phases:
- duration: 60
arrivalRate: 2
scenarios:
- name: "Nashhorn"
flow:
- post:
url: "/casting/nashhorn"
auth:
user: user1
pass: user1
json:
body:
fromFile: "./casting-dataset-01-as-input.json"
options:
filename: "casting_dataset"
conentType: "application/json"
expect:
statusCode: 200
capture:
regexp: '[^]*'
as: 'result'
- log: 'result= {{result}}'
- name: "Nodejs"
flow:
- post:
url: "/casting/nodejs"
auth:
user: user1
pass: user1
json:
body:
fromFile: "./casting-dataset-01-as-input.json"
options:
filename: "casting_dataset"
conentType: "application/json"
expect:
statusCode: 200
capture:
regexp: '[^]*'
as: 'result'
- log: 'result= {{result}}'
如何按顺序运行场景并将每个场景的结果显示在同一个文件中?
预先感谢您的回答
解决方案
据我所知,现有的炮兵逻辑没有一个好的方法来做到这一点。
使用这个测试脚本:
scenarios:
- name: "test 1"
flow:
- post:
url: "/postman-echo.com/get?test=123"
weight: 1
- name: "test 2"
flow:
- post:
url: "/postman-echo.com/get?test=123"
weight: 1
... etc...
Started phase 0 (equal weight), duration: 1s @ 13:21:54(-0500) 2021-01-06
Report @ 13:21:55(-0500) 2021-01-06
Elapsed time: 1 second
Scenarios launched: 20
Scenarios completed: 20
Requests completed: 20
Mean response/sec: 14.18
Response time (msec):
min: 117.2
max: 146.1
median: 128.6
p95: 144.5
p99: 146.1
Codes:
404: 20
All virtual users finished
Summary report @ 13:21:55(-0500) 2021-01-06
Scenarios launched: 20
Scenarios completed: 20
Requests completed: 20
Mean response/sec: 14.18
Response time (msec):
min: 117.2
max: 146.1
median: 128.6
p95: 144.5
p99: 146.1
Scenario counts:
test 7: 4 (20%)
test 5: 2 (10%)
test 3: 1 (5%)
test 1: 4 (20%)
test 9: 2 (10%)
test 8: 3 (15%)
test 10: 2 (10%)
test 4: 1 (5%)
test 6: 1 (5%)
Codes:
404: 20
所以基本上你可以看到它们的权重相同,但运行不均。所以我认为需要为炮兵的代码本身添加一些东西。很高兴在这里犯错。
推荐阅读
- javascript - 在 javascript 数组中均匀分布元素
- javascript - NodeJS - 从 Readdirp 中获取数据
- angular - angular-cli - 模拟缓慢的 HTTP 响应
- c# - 有没有办法通过单击触发 Blazor 中的两个连续事件?
- javascript - PWA 服务工作者在 Firefox 中不起作用
- wordpress - Woocommerce REST API 自动/woocommerce:302 重定向到 www.* 查询
- pandas - 如何从 1 列制作三个不同的虚拟列?
- sql - 如何基于特定的、相同的列值进行聚类
- javascript - 刷新网页后,我的 blob 值如何变化?
- python - Python - 识别连续 0 组并替换它们