csv - 如何在 JMeter 的 while 循环中使用 CSV 数据集配置?

标签 csv while-loop jmeter

我需要针对 5 到 10 个服务器测试相同的一组 url。 URL 在 CSV 文件中定义。服务器名称在用户定义的变量配置中定义。

我正在使用基于服务器数量的 While Controller 来迭代和执行 url 请求。我当前的逻辑定义如下:

Thread group
  While controller
   Counter (defines number of servers)
   While controller (inner check "${URL}" != "<EOF>")
     CSV Data Set Config (stop EOF is true)
       HTTP Sampler (with url data)

根据逻辑,我的脚本将运行并读取一次 CSV 文件并停止。它不是在读取外循环。只有内循环并停止。

最佳答案

引自 JMeter Manual of CSV Data Set :

By default, the file is only opened once, and each thread will use a different line from the file. However the order in which lines are passed to threads depends on the order in which they execute, which may vary between iterations. Lines are read at the start of each test iteration. The file name and mode are resolved in the first iteration.


线程组不能嵌套。 所以你必须使用线程组在 CSV 中进行迭代并使用 foreach 在其他内容中进行迭代 .第二个选项是生成带有 URL+Server 变体的 CSV ,并仅使用单个线程组来读取 CSV。
第一个选项在这里。
迭代 URL 外循环,迭代服务器内循环。你只需要一个线程组和一个 foreach 在里面。看图片:
User defined variables (servers)
enter image description here
enter image description here
enter image description here
示例结果:
enter image description here
enter image description here
enter image description here
当然还有 3 个结果......
你也可以玩CSVRead function如果你有时间 :)

关于csv - 如何在 JMeter 的 while 循环中使用 CSV 数据集配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13093282/

相关文章:

ruby - 创建具有不同 key 的哈希数组的 CSV

mysql - 加载数据本地 infile - 选择忽略最后一列

linux - 遍历 bash 中的参数

javascript - 使用 for 循环检查用户是否输入一周或周末

performance - 如何避免在 JMeter 中重复使用 CSV 文件中的用户

python - 使用 Python 从 csv 文件创建深度嵌套字典

java - 使用 Scanner() 读取 CSV

c++ - 如何递归读取文件而不是 while 循环?

google-app-engine - 使用 JMeter 对 Google App Engine 应用程序进行负载测试

java - 使用 RestTemplate,如何先将请求发送到代理,以便我可以将 junit 与 JMeter 一起使用?