I'm trying to set up a JMeter run that does this:
- Make Rest API request
- Use a JSON Extractor to check the response for a given array of values.
- I define success as all of the "Items[*].Success" nodes equaling "true"
- If the response is successful, break out of the loop (continue to step #5)
- If the response is a failure, go back to step #1
- ... the rest of my test steps
Here's what I've set up to do this:
- Use a BeanShell Assertion to initialize a loop variable:
${__setProperty(is_any_calc_pending,true)};
- While Controller with a condition set to
${__BeanShell(props.get("is_any_calc_pending")}
- My problem is here, the loop never stops
- Make Rest API call (This works as expected)
- JSON Extractor (This also works as expected)
- Names of created variables = api_successes
- JSON Path expressions = $.Items[*].Success
- Match No. = -1
- Compute concatenation = checked
- Default Values = unset_api_successes
- JSR223 PostProcessor set to Javascript to update the value of the loop variable.
Here's my code for step #5. It simply checks whether or not there's a "false" in the api_successes_ALL
variable that the JSON Extractor creates.
var api_successes_ALL = vars.get('api_successes_ALL')
var all_successful = api_successes_ALL.indexOf('false') < 0
props.put('is_any_calc_pending',!all_successful)
Most of this works as I expect; I can check this using the Debug Sampler. The problem I'm having is that the loop never stops. The condition never causes the loop to break.
In the log, I see this line:
DEBUG o.a.j.c.WhileController: Condition value: 'false'
The documentation says that the While Controller will continue until the condition is false. From what I see in the log, the condition is always false. I also don't understand why the While Controller never sees that the value of my is_any_calc_pending
changes. I can see in the Debug Sampler that the value changes.
Is the variable being re-initialized somehow? I'm wondering if my variable or property is going out of scope.