Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter CSV Dataset Config: how to move through variables in the same thread?

I'm using a CSV dataset config element, which is reading from a file like this:

abd
sds
ase
sdd
ssd
cvv

Which, basically, has a number of 3 letter random string.

I'm assigning them to a variable called ${random_3}.

Now, I want to use values from this list multiple times within the same thread, but each time I want to move to next. For example, I want the first sampler to use abd, the 2nd to use sds, then ase, etc. But if I just use ${random_3} then only the first one (abd) is used wherever it's referred to. Is there a way I can specify to loop through the values from the CSV dataset within a thread?

like image 254
Ashkan Aryan Avatar asked Sep 06 '11 09:09

Ashkan Aryan


People also ask

How pass data from CSV in JMeter?

To edit your JMeter script by using the Apache JMeter GUI: Select the CSV Data Set Config element in your test plan. Update the Filename information and remove any file path reference. Optionally, enter the CSV field names in Variable Names, when you split the CSV file across test engines.

What is CSV data set config used for in a JMeter test?

The “CSV Data Set Config” enables using CSV files as an external data source, where you can keep unique user data like names, emails and passwords. With the help of this config element, JMeter is able to read the CSV file line by line, and then use split parameters to allocate different values for different threads.


1 Answers

CSV Data Set Config works fine for this. All of the values need to be in one column in the file and assign them to the variable as described.

Create a Thread Group that has as many threads for as many users as you want iterating over the file (i.e. acting on the HTTP Request). Assuming 1 user, set the number of threads to 1, loop count to 1.

Inside the thread group you will need to add a Loop Controller or a While Controller. You indicated that you want to loop through the whole data set. If you add a loop controller you will want to set the Loop Count to 6, since you have 6 values, one for each value. Alternately (and easier for processing the whole file) add a While Controller instead of a Loop Controller and set ${random_3} as the while condition.

It is important to set the CSV Data Set Recycle on EOF and Stop Thread on EOF values correctly. If you plan to iterate over the file more than once you must set "Recycle on EOF" to True (i.e. instruct jMeter to move back to the top of the CSV file). Set "Stop Thread on EOF" to False if you are using a loop controller, true if you are using a while controller and want to stop after reading the whole csv dataset.

Add the CSV Data Set Config as a child of the controller along with the HTTP Request. View the results using any listener you want to use.

like image 149
TechTrip Avatar answered Oct 12 '22 23:10

TechTrip