I am doing teacher tool testing in JMeter. I have 30 number of entries in .csv file. I want to iterate first 10 entries through any logic controller for thread one and other 10 entries with same controller for second thread and this process should be repeated 3 number of threads. inside logic controller i have http sampler.
Thread Group (3)- csv config file- foreach controller(1-10)- http sampler-
repeat foreach loop controller(11-20)
Define an child CSV Data Set Config , with the file path and the variable name url which stands for the column listing the urls. Use the ${url} with the http request handler to fire the request. To stop execution after the end of the CSV file is reached: within the CSV Data Set Config set Recycle on EOF?
ForEach Controller in Jmeter iterates through an array of variables. In this JMeter tutorial, we'll use the ForEach Controller to loop through a JSON Array. There are times when we need to parse a response and extract certain information from it.
In CSV file, add another column (say B) apply =RAND() function in the first cell of column B (say B1). This will create random float number.
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.
As far as I understood your question you need the following:
In order to implement this you'll need the following test plan structure:
In regards to detailed configuration
Beanshell Sampler
Put the following code into Beanshell Sampler Script area:
BufferedReader br = new BufferedReader(new FileReader("/path/to/your/file.csv"));
String line;
int counter = 1;
while ((line = br.readLine()) != null) {
vars.put("VAR_" + counter, line);
counter++;
}
br.close();
The code above will read all the lines from file.csv
and store it into JMeter Variables like:
VAR_1=first line of your CSV file
VAR_2=second line of your CSV file
VAR_3=....
If Controller 1
If you want anything under this controller to be applicable for 1st user only set the following condition:
${__threadNum}==1
ForEach Controller 1
If you want 1st thread to read first 10 lines from CSV file configure your ForEach Controller 1 as follows:
VAR
0
10
CURRENT_VAR
HTTP Request 1
Refer current line as ${CURRENT_VAR}
where required.
Hope it's clear enough.
References and how-to's :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With