gpt4 book ai didi

node.js - 通过 Postman Newman 并行运行多个请求以对 API 进行负载测试

转载 作者:行者123 更新时间:2023-12-02 19:49:22 31 4
gpt4 key购买 nike

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

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

由于我缺乏 Node.js 控制台命令的知识,我无法运行脚本文件。使用 Postman 集合列表运行此批处理/文本文件的正确语法是什么?

我尝试过:

作为上面链接的开发人员建议我创建 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 并以相同的方式运行,但使用 .sh 扩展名。还是没有运气。

如何从此处的文件运行同步 API 调用?

最佳答案

  1. 您所引用的文章中的建议是关于 Bash ,我不知道你为什么要谈论 Node.js。
  2. 本文中的建议均适用于顺序执行多个测试
  3. 您无法应用任何这些说明,因为查看 c:\ 驱动器,您似乎正在使用 Windows 操作系统

如果您想在 Windows 中启动多个并行版本的 newman 进程(无论它是什么)cmd.exe解释器使用 start 是有意义的命令如下:

  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 测试执行没有任何问题,并且在测试结束时,您将获得漂亮的表格和图表,因为我看不到您将如何使用 Postman/newman 分析“负载测试”的结果。

关于node.js - 通过 Postman Newman 并行运行多个请求以对 API 进行负载测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58532553/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com