Home > Back-end >  Retrying GET request until a certain value from http response in JMeter is present
Retrying GET request until a certain value from http response in JMeter is present

Time:07-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

CodePudding user response:

  1. Put your HTTP Request sampler under the Loop Controller

  2. Add enter image description here

  3. Add enter image description here

  • Related