0

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

safary
  • 325
  • 2
  • 7
  • 26

1 Answers1

1

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.

Naveen Kumar R B
  • 6,248
  • 5
  • 32
  • 65
  • Added debug sampler and updated test with different logic for controller. – safary Sep 23 '16 at 10:06
  • Remove HTTP Cache Manager and try. may be HTTP Request is not sent as Jmeter find cache response is fresh, so id did not send HTTP Request. I simulated the same scenario and it is sending both "HTTP Request" and "D: After Request" as the regex value is matching with the condition (true). – Naveen Kumar R B Sep 23 '16 at 11:02
  • Without cache manager test stopped after first request logon-get, but then I added it again and test succeeded. Problem I guess was in cache manager settings, because after reading some example with while controller, I checked in cache manager: clear cahce each iteration and use cache-control/expires header when... So after removing those two checks, everything worked. Thank you very much for help! – safary Sep 23 '16 at 12:45
  • Yes. cache manager, you can configure whether you want to keep/use the cache or remove after every iteration (first check box) - clean cache on each iteration. If checked, simulates new user visiting the web app. if not checked, simulates existing users coming back to web app. ever thing is based on your Work Load Distribution. – Naveen Kumar R B Sep 23 '16 at 12:59