Jmeter: how to iterate over csv file in batches?

Stefan Alexandru

I have to conduct a test in Jmeter that uses a csv file as data source.

The requirement of the test is that for each request (the test needs to have 100 requests), 10.000 rows from the csv need to be processed.

To summarize, this is how the test should look like:

request 1 -> iterate over the first 10.000 rows (1-10.000) request 2 -> iterate over the next 10.000 rows (10.001 - 20.000) ... ... request 100 -> iterate over rows 990.001 - 1.000.000

I am new to Jmeter so I hope I was able to explain what I have to do, but in case you need more details please let me know.

So basically, is there an easy way to do this by adding some sort of controller or does it require a JSR223 sampler with some code in it?

Thank you.

I am testing an application that stores use to mark products as "sold", the requirement is to check how the app behaves when they are selling 100 batches each containing 10.000 products.

The test also has a sampler with a SOAP request, there is a node in the soap request xml containing the product serial number, initially I tried hardcoding 10.000 serial numbers under this parameter but the result wasn't the expected one.

Dmitri T

I would go for splitting the original "large" CSV file into smaller CSV files containing 10 000 rows each.

  1. Add setUp Thread Group to your Test Plan
  2. Add JSR223 Sampler to the Thread Group
  3. Put the following code into "Script" area:

    SampleResult.setIgnore()
    
    def largeFile = new File('largefile.csv')
    
    def i = 0
    def smallFilePostfix = 0
    def smallFile = new File('smallfile' + smallFilePostfix + '.csv')
    largeFile.each { line ->
        if (i >= 10000) {
            i = 0
            smallFilePostfix += 1
            smallFile = new File('smallfile' + smallFilePostfix + '.csv')
        }
        i = i + 1
        smallFile << line << System.getProperty('line.separator')
    }
    
  4. That's it, the above code will split largefile.csv into smallfile0.csv, smallfile1.csv, etc. each containing 10 000 lines which can be used normally using i.e. __CSVRead() function

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I iterate over all the batches from DataLoader?

how to split csv file data in batches?

How to iterate over the file in python

Iterate over columns of a csv file bash script

Function parameters iterate over a csv file values

How to iterate a CSV file in bash?

How to iterate over Max Values for Fuzz Ratio and export to new CSV file

How to iterate over a CSV file and update values in one column based on the value of another column

How to iterate over rows of .csv file and pass each row to a time-series analysis model?

How to safely iterate over an IAsyncEnumerable to send a collection downstream for message processing in batches

How to iterate over a property file in Spring xml

How to iterate over this file containing constants array

How to iterate over a xml file by xmlstarlet

Iterate over CSV file and run await for each row?

Iterate over cells in a CSV file in Node.js

DRF - upload CSV file then iterate over each row

How do i iterate through CSV in jmeter creating new thread

Cannot iterate over a file?

How to use csv file with ForEach controller in JMeter

How to use cell values of .csv file in jmeter?

How to iterate over rows and print out CSV::Table values in Sinatra

How to iterate over XML tags in Python using ElementTree & save to CSV

Iterate over rows and save as csv

How to break larger CSV into smaller batches of CSV?

How to iterate over multiple imported modules from index file

How to iterate over an audio file in 20s intervals?

How to iterate over a file with huge no of lines to find a string?

How to iterate over directory and perform task on each individual file

How to import data from .JSON file and iterate over it in React?