prav kum
prav kum

Reputation: 454

JMeter to get the data from mutlple csv files for http sampler

I will have n (not fixed number of files) number of csv files, and these files should be passed as input to http sampler request. The plan is that all the threads should read the data from csv file1 and file2... till file n. There should not be any duplicate data read for any of the thread.

currently i have the jmeter script to read the data from 1 csv file and it is working fine, So same has to be extended to read the data from multiple csv files.

Upvotes: 0

Views: 219

Answers (2)

Dmitri T
Dmitri T

Reputation: 168147

I believe the easiest solution would be combining all the multiple CSV files into one prior main logic of your test begins.

  1. Add setUp Thread Group to your Test Plan. The idea of the setUp Thread Group is that it is being run before any other Thread Group so you can use it for test data generation
  2. Add JSR223 Sampler to the setUp Thread Group
  3. Put the following code into "Script" area:

    def combined = new File('combined.csv')
    combined.text = ''
    
    combined.withWriter { writer ->
        new File('/path/to/folder/with/your/CSV/files').listFiles().each { file ->
            file.withReader { reader ->
                writer << reader << System.getProperty('line.separator')
            }
        }
    }
    
  4. Configure the CSV Data Set Config to use combined.csv filet

Upvotes: 1

Arjun Dev
Arjun Dev

Reputation: 414

Use Directory Listing Config plugin. Please go through the below link.

https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/directory-listing/DirectoryListing.md

There are other methods as well for iteration multiple files in jmeter, but this would be the easiest way to do it.

Upvotes: 0

Related Questions