Search code examples
jmeterperformance-testingload-testingjmeter-5.0web-api-testing

How to run the same sampler in Jmeter until I get specific result in response data Json


I want to run the same sampler until I get polling_status": "success", it will be inprogess for some time after few sec will get success ststus. Until the status changes to success I want to run the same sampler. Once the status change I want to move to next sampler. How can I achive this in Jmeter?

I have highlighted it which value will change

{
    "data": {
        "trip_id": "003",
        "selection_id": "d80acc5311",
        "polling_start_time": "2023-06-07 14:11:11.841000",
        "leg_info": [
            {
                "selection_status": 1,
                "user": "8"
            }
        ],
        
    *"polling_status": "inprogress",*

        "selection_status": 0,
        "polling_starts": true
    },
    "selection_id": "e8550872-c3dd-4f5e-827b-68d80acc5311",
    "status": "success",
    "statusCode": 200
}

Solution

    1. Put your request under the While Controller and use the following __jexl3() function as the condition:

      ${__jexl3("${status}" != "success",)}
      

      enter image description here

    2. Add JSON Extractor as a child of the request and configure it as follows:

      enter image description here

    3. That's it, the While Controller will run the request until polling_status attribute value is not success, once it becomes success it will exit the loop and proceed to the next Samplers or Controllers. Something like:

      enter image description here