1
votes

My Test plan has a csv dataset config element, a thread group with a http sampler. I would like to read first element from csv, run it using 20 threads for 50 iterations, then repeat this sequential process for all the 30 rows of my csv. I have set the toggle for stop on eof to true.

Most solutions,I have gone through on Stack Overflow, andother blogs, for a suitable solution, suggest adding a loop controller or a while loop, reading the rows using a preprocessor and looping, however, in these cases, I am not able to achieve my objective.

TestPlan

-- User Defined Variables
-- HTTP Request Defaults
-- HTTP Header Manager
-- JSR223 PreProcessor (To get the CSV line count)
-- CSV Data Set Config (Recycle on EOF - False, Stop on EOF - True)
-- Thread Group
-- HTTP Sampler (GET,pass each of the csv dataset element as part of path)
-- View Result Tree

With the above setup, I see that the whole csv is iterated, I inlcuded a loop controller, with loop count, moved the HTTP sampler, under it. However, when I do this, I was unable to get the usage of Iterations in thread-group.

Article References:

Use same row per thread from a CSV data set in JMeter

How to read each and every row of csv by single user in JMeter?

How to loop each thread with unique data from CSV Data Config file

JMeter - multiple user taking unique row from CSV file

1
Link to what you have researched and explain why it didn't work for you. Show what you have tried, so that others can help fix what you have. Without doing that, you are expecting someone else to solve your problem for you from scratch. Maybe take a look at how to ask.Richardissimo
@Richardissimo, Thank you, for the comment, missed attaching the artifacts. Please refer, updated above. Appreciate sharing the article above, btw, never had the expectation of someone solving my query, from scratch.Srirahul K

1 Answers

1
votes

Your requirement is too "exotic", I would recommend creating a new CSV file out of your existing one with:

  • 1st line repeated 100 times (20 threads x 50 iterations)
  • 2nd line repeated 100 times
  • 3rd line repeated 100 times
  • ...
  • 30th line repeated 100 times

If you have problems generating the file you can do this in the runtime, like:

  1. Add setUp Thread Group with 1 thread and 1 loop to your test plan
  2. Add JSR223 Sampler to the Thread Group
  3. Put the following code into "Script" area:

    SampleResult.setIgnore()
    def generated = new File('/path/to/new/csv/file')
    generated.delete()
    new File('/path/to/old/csv/file').readLines().each { line ->
        1.upto(100, {
            generated << line << System.getProperty('line.separator')
        })
    }     
    
  4. In main Thread Group use CSV Data Set Config "normally", just point it to use the /path/to/new/csv/file

See The Groovy Templates Cheat Sheet for JMeter for more examples of useful Groovy code snippets which you can use to enhance your JMeter tests.