I have an http request sampler1 and extracting a 'JobID' value using regular expression extractor. Now, i have http request sampler2 to check a job status in the same thread group which uses 'JobID' from previous regular expression extractor. The sampler2 has a while loop controller with condition ${__javaScript("${Status}"!="Ready",)} which is to say keep executing the sampler until status is Ready. The variable 'Status' is again got using regular exression extractor associated with sampler2. Now, the issue is when i run more than 1 thread, the second sampler stops executing after the 1st run once the job status is Ready and does not execute with the next JobID from the sampler1. Is it due to the While controller? Any inputs on this would be of great help. Thank you!
0
votes
1 Answers
0
votes
Of course it doesn't.
If you have more than one iteration in Thread Group or your both Samplers live under the Loop Controller, when 2nd iteration starts your ${Status}
variable has the value of Ready
so JMeter doesn't enter the While Controller as the condition is not met.
If you want to run more than one iteration you need to reset the ${Status}
variable value somehow, one of ways is using JSR223 Sampler and the following code:
SampleResult.setIgnore()
vars.put('Status', 'Not ready')
Example setup:
In the above code snippet:
- first line removes the JSR223 Sampler from Listeners/.jtl results file,( you're not interested in its timings, are you?)
- second line sets
${Status}
variable toNot ready
using vars shorthand for JMeterVariables class instance (see Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on JMeter API shorthands available for JSR223 Test Elements)