Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read csv value in loop controller Jmeter

Tags:

loops

csv

jmeter

I have a loop controller in thread groups to read one csv file and i want to read all line in this csv file. I config my thread group as below:

  • Loop Controller (4 times)
    • Read csv file (Recycle on EOF: False, Stop thread on EOF: True, Sharing mode: All threads)

I run this scenario with a number of threads: 2

  • With first thread, read the first line of CSV file

  • With second thread, read the second line of CSV file

After each loop, i got data from CSV file is not changed, so how can i read each line of csv (from 3rd line,...) after the loop?

like image 735
Alex Le Avatar asked Nov 02 '25 05:11

Alex Le


1 Answers

You have to put CSV Data Set Config as a child of Loop Controller.
It should work for you with CSV Data Set Config settings you specified. I create Test Plan:


    Thread Group
    Number of Threads = 2
        Loop Controller
        Loop Count = 4
            CSV Data Set Config
            Filename: ... (your csv-file here)
            Variable Names: number
            Delimiter: ,
            Recycle on EOF = False
            Stop Thread on EOF = True
            Sharing Mode = All threads
            JSR223 Sampler
            log.info(vars.get("number"));     // output ${number} variable values

Each Loop my "CSV Data Set Config" reads line into a "number" variable.
JSR223 Sampler print it's value to Log Viewer.

My CSV file looks like

1
2
3
4
5

So, because of Recycle on EOF is FALSE, Stop thread on EOF is TRUE the first Thread read 4 lines in the loop and the second Thread read just one the 5th line and then stop.

See the picture

like image 90
Vadim Yangunaev Avatar answered Nov 04 '25 03:11

Vadim Yangunaev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!