How to use CSV data set config inside a while loop in JMeter?

六月ゝ 毕业季﹏ 提交于 2019-11-30 05:05:00

问题


I need to test the same set of urls against 5 to 10 servers. URLs are defined in the CSV file. Server names are defined in User Defined Variables config.

I'm using While Controller based on the number of servers to iterate and execute the url requests. My current logic is defined as below:

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)

As per the logic my script will run and read the CSV file once and stop. It's not reading the outer loop. Only inner loop and stopped.


回答1:


Quote from 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.

Thread groups cannot be nested. So you have to use the threadgroup to iterate in CSV and foreach to iterate in something else. The second option is to generate a CSV with the URL+Server variations, and using simply a single threadgroup to read the CSV.

First option is here.

Iterating URLs outer loop, iterating servers inner loop. You just need a threadgroup and a foreach inside it. See the pictures:

Sample results:

And of course 3 more results...

You can also play with CSVRead function if you have time :)



来源:https://stackoverflow.com/questions/13093282/how-to-use-csv-data-set-config-inside-a-while-loop-in-jmeter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!