运行 通过 Postman Newman 并行进行多个请求以负载测试 API

Running multiple requests in parallel via Postman Newman to load test the API

我不是 Node.js 开发人员,但我安装 Newman Postman 只是为了能够加载测试我的 API。

我想利用下面 link 中建议的一个简单想法,从一个批处理文件并行处理 运行 多个 API 请求。资料来源:https://community.getpostman.com/t/how-can-i-run-simultaneous-request-parallely/3797/2

由于我对 Node.js 控制台命令缺乏了解,我无法 运行 编译脚本文件。 运行 这个包含 Postman 集合列表的 batch/text 文件的正确语法是什么?

我试过了:

作为上述 link 的开发人员,我建议创建 myfile.txt 文件并插入:

newman run c:\path...\collection.json -e c:\path...\staging.json &
newman run c:\path...\collection.json -e c:\path...\staging.json &
newman run c:\path...\collection.json -e c:\path...\staging.json

然后我 运行 文件包含:

newman run c:\path...\myfile.txt

失败。

然后尝试运行以这种方式创建文件:

node c:\path...\myfile.txt

运气不好。 然后我尝试在文件中添加 #!/bin/bash 并以相同的方式添加 运行ning 但扩展名为 .sh。 仍然没有运气。

如何从此处的文件 运行 同时 api 调用?

  1. 您提到的文章中的建议是关于 Bash,我不知道您为什么要谈论 Node.js。
  2. 文章中的建议都是针对顺序执行多个测试
  3. 您无法应用这些说明中的任何一个,因为查看 c:\ 驱动器您似乎使用的是 Windows OS

如果你想在 Windows cmd.exe interpreter it makes sense to use start 命令中启动多个并行版本的 newman 进程(无论它是什么),例如:

  1. 创建文件myfile.cmd
  2. 将以下行放在那里:

    start newman run c:\path...\collection.json -e c:\path...\staging.json 
    start newman run c:\path...\collection.json -e c:\path...\staging.json 
    start newman run c:\path...\collection.json -e c:\path...\staging.json
    

但是我宁愿推荐使用专门的负载测试工具,有多种 free and open source load testing solutions 在并行 API 测试执行和测试结束时没有任何问题你会得到漂亮的表格和图表,因为我看不出你将如何分析你的 "load test" 和 Postman/newman 的结果。