Reputation: 27
I have a following situation. I need to wait for a certain value from get request from response body. I need to loop this quest and when the desired value is present in response, exit the loop, and call new request that needs to execute as well in loop until another value is shown in response.
Thing is I have Thread Group ( In thread group I've set 'Loop Count' to 3, but it will be dynamically set based on previous tests, but for the sake of explaining my situation let's say its 3 loops. ) and in that Thread Group i have a CSV Data Set Config from which I use IDs that I pass into the GET request (also for the sake of example have 3 rows and in each row unique ID).
So basically I would like to iterate through my Thread Group 3 times, using different IDs on each iteration for GET requests (one of IDs from CSV rows ), but to retry a GET request a number of times ( infinite isn't an option, so lets say 200 times ) until it's response contain certain value or cancel the test.
Ideal scenario would be like this:
GET request with id='123' => check in response if the value that I need is there, if not
RETRY GET request with id='123' = > check in response if the value that I need is there, if not
RETRY GET request with id='123' = > check in response if the value that I need is there, if there:
start new GET request with id='456' => check in response if the value that I need is there, if not
RETRY GET request with id='456' = > check in response if the value that I need is there, if not
RETRY GET request with id='456' = > check in response if the value that I need is there, if not
200th RETRY with no value that i need - exit the test
Upvotes: 0
Views: 1625
Reputation: 168072
Put your HTTP Request sampler under the Loop Controller
Add If Controller after the HTTP Request and use the following __groovy() function as the condition:
${__groovy(prev.getResponseDataAsString().contains('value-you-are-looking-for'),)}
replace value-you-are-looking-for
with the actual anticipated value
Add Flow Control Action sampler as a child of the If Controller and set it to Break Current Loop
Upvotes: 2