Attempting to create a request with JMeter where the request has to retry until a JSON variable ($.result.status) of the response meets the expected result. In detail, the request should retry untill the value of the variable turns into "completed" from "pending" state.
For this I have used to a While Controller with the following JS condition. It works perfectly in the 1st iteration/loop and exits the While-Controller once the resultStatus turned into "completed"
${__javaScript("${resultStatus}" == "pending" || "${resultStatus}" != "completed" || "${resultStatus}" == "" )}
But, from the 2nd loop onward the While-Controller is getting skipped.
I assume the reason was because the resultStatus variable was assigned to "completed" along with the exit for the While-Controller in the 1st loop and remains as it is when it comes to the While controller in the second loop. Therefore the condition is getting false..
With that assumption, I tried vars.remove for BeanShellPostProcessor in While-Controller with following code snippet. But it didn't resolve my issue.
String x = vars.get("resultStatus");
if ( x == "completed"){
vars.remove("resultStatus", "completed");}
Below is the structure of the Jmeter Tree.
- Red Box : While Controller
- Red Arrow Point : Response Variable Change
from Pending to Completed and Step-in to Loop 2
Could it be the reason I assumed for this issue of skipping the While controller from 2nd loop?
If it is; What is approach I should take to clear the variable value?
If it is not the reason I assumed, Can I kindly get assisted with the reason and a solution?