How to use csv file with ForEach controller in JMeter

I am testing instrumentation tools in JMeter. I have 30 entries in a CSV file. I want to iterate the first 10 records through any logical controller for a thread and the other 10 records with one controller for a second thread, and this process should be repeated 3 numbers of threads. inside the logic controller i have http sampler.

Theme group (3) - csv config file- foreach controller (1-10) - http sampler -

repeat foreach loop controller(11-20)
+4
source share
1 answer

As far as I understand your question, you need the following:

  • Read all values ​​from a CSV file
  • For the first iteration stream of the first 10 entries
  • For the second stream of iteration of the second 10 entries
  • etc..

, :

  • - , , ..
    • Beanshell Sampler - CSV JMeter
    • 1 ( 1- )
      • ForEach 1
      • HTTP
    • 2 ( )
      • ForEach 2
      • HTTP
    • ...

>

Beanshell Script:

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();

file.csv JMeter Variables, :

VAR_1=first line of your CSV file
VAR_2=second line of your CSV file
VAR_3=....

1

, - 1- , :

${__threadNum}==1

ForEach 1

, 1- 10 CSV, ForEach 1 :

  • : VAR
  • : 0
  • : 10
  • : - , .. CURRENT_VAR

HTTP- 1

${CURRENT_VAR}, .

, .

:

+6

All Articles