1

I'm concerned with work of CSV Data Set Config along JMeter rules set with scoping rules and execution order.

For CSV Data Set Config it is said "Lines are read at the start of each test iteration.". At first I thought that talks about threads, then I've read Use jmeter to test multiple Websites where config is put inside loop controller and lines are read each loop iteration. I've tested with now 5.1.1 and it works. But if I put config at root of test plan, then in will read new line only each thread iteration. Can I expect such behaviour based on docs only w/out try-and-error? I cannot see how it flows from scoping+exec order+docs on csv config element. Am I missing something?

I would appreciate some ideas why such factual behaviour is convenient and why functionality was implemented this way.

P.S. how can I read one line cvs to vars at start of test and then stop running that config to save CPU time? In 2.x version there was VariablesFromCSV config for that...

Alex Martian
  • 3,423
  • 7
  • 36
  • 71

1 Answers1

3
  1. The Thread Group has an implicit Loop Controller inside it:

    enter image description here

    the next line from CSV will be read as soon as LoopIterationListener.iterationStart() event occurs, no matter of origin

  2. It is safe to use CSV Data Set Config as it doesn't keep the whole file in the memory, it reads the next line only when the aforementioned iterationStart() event occurs. However it keeps an open file handle. If you do have really a lot of RAM and not enough file handles you can read the file into memory at the beginning of the test using i.e. setUp Thread Group and JSR223 Sampler with the following code

    SampleResult.setIgnore()
    
    new File('/path/to/csv/file').readLines().eachWithIndex { line, index ->
        props.put('line_' + (index + 1), line)
    }  
    

    enter image description here

    once done you will be able to refer the first line using __P() function as ${__P(line_1,)}, second line as ${__P(line_2,)}, etc.

    enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133