Search code examples
javascriptjmeterjmeter-plugins

Jmeter while controller gets stuck on request and does not loop


I am writing a test that waits for a specific response using while controller. To be more precise, I send a message with jmeter, then that message gets state "sending" and after about 30 seconds it state changes to "received". So using while controller I try to get how much time that message needs to get received.

  1. So I create "State" variable and give him value "not set yet"
  2. Set while controllers condition to ${__javaScript("${State}".indexOf("Received") == -1,)}
  3. Then in while controller I add http request item with that page which should contain received state when it changes
  4. In http request I add regex extractor which should take all response text with reg expression set to "(.+)" and reference name to "State"
  5. Add constant timer with 5 sec in http request

When I execute this test, it gets stuck after http request, which is executed in green and nothing happens next, what can be the problem here?

UPDATE ---------------------------------------------------------------------

Siunčiamas=Sending

Tried something different. Changed while controller value to -

${__javaScript("${State}" == "Siunčiamas",)}

and reg expression extractor value to -

class="label-primary label" id="parentSyncState">(Siunčiamas)<

and before while controller I'm giving State variable value "Siunčiamas"

Now it stucks on http request, but I added debug sampler after it, so it keeps repeating every 5 seconds. But it should be looping until regex extractor does not find required value and return default value which is not equal to "Siunčiamas" so while controller fails. Am I not getting something here?

Screenshot


Solution

  • It is not looping means, condition in While controller is not satisfied, not returning true.

    By the way, ${__javaScript("${State}".indexOf("Received") == -1,)} means that, condition is true when State does not contains Received.

    • indexOf returns -1 in case the string is not found in the parent (State)

    First time, it ran because, you set State to not set yet, where condition returns true (indexOf returns -1 as "not set yet" does not contains "Received")

    When I execute this test, it gets stuck after http request, which is executed in green and nothing happens next, what can be the problem here?

    Does the test stopped or still running?

    1. If test is stopped, you can assume that condition is failed (which mean State contains "Received"), so while controller is stopped sending the requests and comes out. overall execution time of while controller gives (number of times http request has been sent* (http request response time + 5 seconds)) the time required to get the "Received" message. Note: Add While Controller as a child to Transaction Controller to get the overall execution time.
    2. If test is still running, something wrong in your test design. expected is that every 5 seconds, http request should be SENT.

    Add Debug Sampler to know what value is captured by State variable using Reg Ex Extractor.

    Following is the screen shot that how i understood the scenario.

    enter image description here

    Share your Test Plan with us in order to help you.