I am trying to come up with jmeter setup in which i want to read entire csv file that has 200000 rows and i want iterate through each rows creating new thread since i am using JSR223 pre-processor that requires new thread for removing empty parameters from the request body. For some reason when i use while loop then only first test passes and rest of the tests fails as JSR223 pre-processor keeps on reading previous thread. I have also un-checked cached compiled script if available but still no luck. I also want to add that when i explicitly specify the number of threads as 100 out of 200000 then all of my 100 test passes as it reads new thread each time. Below is the screenshot of my set up:
This Fails -
This Passes -
JSR223 Pre-Processor Script that i am using:
def request = new groovy.json.JsonSlurper().parseText(sampler.getArguments().getArgument(0).getValue())
def newRequest = evaluate(request.inspect())
request.body.each { entry ->
if (entry.getValue().equals('')) {
newRequest.body.remove(entry.getKey())
}
}
sampler.getArguments().removeAllArguments()
sampler.addNonEncodedArgument('', new groovy.json.JsonBuilder(newRequest).toPrettyString(), '')
sampler.setPostBodyRaw(true)
Console log when using while controller
Replace this :
sampler.getArguments().removeAllArguments()
By:
def arguments = new org.apache.jmeter.config.Arguments();
sampler.setArguments(arguments);
If you're looking to learn jmeter correctly, this book will help you.