0
votes

I am setting the JMeter properties using JSR223 outside of WHILE controller like this -

if(jsonResponse.currentStatus == "Received")
{   
    props.put("pollCount", 0); 
    def requestId = jsonResponse.id;
    props.put("requestId", requestId); 
    props.put("currentStatus",jsonResponse.currentStatus);
}

Then I am accessing these properties within "WHILE" Controller like this-

((("${__groovy(props.get('currentStatus'))}" == "Received") ||
("${__groovy(props.get('currentStatus'))}" == "Processing")) &&
(${__groovy(props.get('pollCount'))} < 24)) 

Within the WHILE Controller, I am making an HTTP request to recheck the "currentStatus". If it is "completed" then my idea is, I'll come out of the "WHILE" controller.

Similarly, I have an "IF Controller" within "While Controller". After making an HTTP call and checking the "currentStatus". Then I am resetting "props" properties. If "currentStatus" is "Received" or "Processing", I go inside "IF Controller", where I am providing a timer delay of 30 seconds with constant timer. In the "IF Controller", I am applying the condition like this -

(("${__groovy(props.get('currentStatus'))}" == "Received") ||
("${__groovy(props.get('currentStatus'))}" == "Processing"))

But it does not go inside the IF controller, even if the condition is "Processing".

The "While Controller" keep on processing infinitely even if the "currentStatus" is set to "Completed".

It seems that the conditions are not working for me. How can I fix it so that when "currentStatus" is "Completed", it comes out of the "WHILE Controller"?

2

2 Answers

0
votes

Have you checked putting only one condition in while controller ?

0
votes

There are multiple problems with your setup:

  1. I see that you're setting pollCount to 0 however I fail to see where you're incrementing it therefore my expectation is that it will always be 0
  2. Your currentStatus seems to always be Received
  3. Your props.get('pollCount'))} < 24 expression will fail because you're comparing an Integer to a String
  4. And the most important, While Controller "understands" only true or false criteria, it will not evaluate 3 __groovy() functions therefore you should put your multiple clauses into a single function, something like:

    ${__groovy((props.get('currentStatus').equals('Received') || props.get('currentStatus').equals('Processing')) && (props.get('pollCount') as int) < 24,)}
    

Check out 6 Tips for JMeter If Controller Usage article for more details on conditional Samplers processing in JMeter

6 Tips for JMeter If Controller Usage