I need to iterate a request multiple times in JMeter for different users. The iteration number differs for each users. For example: I need to iterate a request 5 times for first user, 3 times for second user and only 1 time for 3rd user and so on. How can we do this and how the input can be fed to the same. Is it possible to say read first 5 line for first user and next 3 lines for second user in csv data set config.
2 Answers
You can define the desired loops count for each user in the CSV file or via JMeter Properties
You can read the desired line from the CSV file using __groovy() function like:
${__groovy(new File('test.csv').readLines().get(0),)}
- read 1st line${__groovy(new File('test.csv').readLines().get(1),)}
- read 2nd line- etc.
Here is a solution for your problem. There could be many other solutions available in JMeter.
You can define the loop count associated with the users (threads) in a (User Parameters)enter link description here Pre-processor.
This panel allows you to specify a series of values for any User Variable. For each thread, the variable will be assigned one of the values from the series in sequence. If there are more threads than values, the values get re-used.
Then the requests can be placed within a Loop Controller
The User Parameters component shall be placed within a JSR223 Sampler to ensure the values are initiated before the loop controller is reached. Also the JSR223 Sampler shall be placed within a Once Only Controller to ensure the Sampler is executed only once.
Add SampleResult.setIgnore()
in the JSR223 Sampler to avoid the sampler getting recorded into the test results.
Test plan structure
CSV Data Set Config more suitable for large numbers of parameters