Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter loop until a response value changes

Tags:

jmeter

I would like to accomplish the following workflow using JMeter

  • Get the results from a URL call (Ex: http://somewhere.com/getResults)
  • If the response message contains "someVar=SUCCESS" the JMeter test will pass
  • else if the response message contains "someVar=FAIL" the JMeter test will fail
  • else if the response message is different, wait x seconds and try the block of code again. Attempt to retry the block of code a maximum of y number of times.

Is something like this possible in JMeter? If so, does anyone have an example?

like image 859
user2992188 Avatar asked Jan 17 '14 16:01

user2992188


2 Answers

This tutorial should fully answer your need:

  • http://www.sourcepole.ch/2011/1/4/waiting-for-a-page-change-in-jmeter
like image 107
pmpm Avatar answered Oct 10 '22 19:10

pmpm


The most straightforward way to go is using JMeter Assertions.

The most powerful of them is Beanshell Assertion.

In regards to your use cases following code sample may help:

if new String(data).contains("someVar=SUCCESS")
    Failure = false;
else
    Failure = true;

Similarly for FAIL

For retrying you can use While Controller using some variable as condition like continue which is set to true. Retry as many times as required, when you're fine - just set continue variable to false.

like image 43
Dmitri T Avatar answered Oct 10 '22 19:10

Dmitri T