我正在尝试在 .yml 中编写一个包含多个场景的 taurus 测试(例如 ping 主机请求、更改机器上的主机名、安装 java 等)。 每个场景都有一个 API 调用请求,带有 url、POST 方法和正文。
问题一:
每个场景都应该在单独的文件中开发,测试应该这样调用:“bzt scenario_1.yml scenario_2.yml,...”。
有没有include_scenario,import之类的解决方案?
例如,在 Ansible 中有 include_tasks,所以我可以调用其他 .yml 脚本,一切都很好。
问题2:
我如何为主体创建某种循环,以便我的 API 请求将为每个分布使用不同的参数。因为我正在尝试编写一个具有高并发性的测试,例如 ping、更改主机名并为 Ubuntu、Debian、Centos 等安装 Java。
当前代码示例:
---
execution:
- iterations: 2
concurrency: 1000
ramp-up: 20m
scenarios:
ping:
requests:
- url: http://127.0.0.1:12121/ping/
method: POST
label: ping
body-file: ./vars/"{{ping}}"
headers:
Content-Type: application/json
parameters:
- /debian/ping.json
- /ubuntu/ping.json
- /centos7/ping.json
changeHostname:
requests:
- url: http://127.0.0.1:12121/changeHostname/
method: POST
label: ping
body-file: ./vars/"{{change_hostname}}"
headers:
Content-Type: application/json
parameters:
- /debian/hostnameDto.json
- /ubuntu/hostnameDto.json
- /centos7/hostnameDto.json
changeRootPassword:
requests:
- url: http://127.0.0.1:12121/changeRootPassword/
method: POST
label: ping
body-file: ./varss/"{{change_root_password}}"
headers:
Content-Type: application/json
parameters:
- /debian/changeRootPasswordDto.json
- /ubuntu/changeRootPasswordDto.json
- /centos7/changeRootPasswordDto.json
reporting:
- module: console
- module: final-stats
settings:
check-interval: 5s
default-executor: jmeter
provisioning: local
谢谢。
最佳答案
YAML 中有一个设置可以包含其他配置文件:
included-configs:
- additional-local-file.yml
- another-config.yml
关于linux - 多场景多参数测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47755294/