1

I want to let JMeter exit while controller when response value "model_name": "Model-Corpus-JMeter2-0001-v1-8k" is found in response data.

sample response data:

{
    "message": "success",
    "valid_model_list": [{
            "meta_data": {
                "corpus_list": [
                    "test1"
                ],
                "id": "1",
                "sample_rate": 16000,
                "test_duration": "0.17 hrs"
            },
            "model_name": "Model-Corpus-JMeter2-0001-v1-8k",
            "status": "ok"
        },
        {
            "meta_data": {
                "corpus_list": [
                    "test1"
                ],
                "id": "2",
                "sample_rate": 16000,
                "test_duration": "0.17 hrs"
            },
            "model_name": "testmod2-v1-8k",
            "status": "ok"
        }
    ]
}

I have set while controller condition ${__jexl3("${model_name}" != "Model-Corpus-JMeter2-0001-v1-8k",)}

The JSON expression is tested works to extract a list of "model_name".

however, the GET request isn't exiting when the response value is already there.

Debug Sampler: captured model_name_18=Model-Corpus-JMeter2-0001-v1-8k

enter image description here enter image description here

enter image description here

enter image description here

1 Answer 1

0
  1. Your "sample response data" is not a valid JSON, you won't be able to use JSON Extractor on invalid JSON objects. Check it yourself - https://jsonlint.com/
  2. Even if your JSON is correct your JSON Extractor configuration will return the first model name, not the "list", to get the "list" you will need to set "Match No" to -1
  3. It's not clear what is the value of the model_name variable, you can check it using Debug Sampler and View Results Tree listener combination
  4. You're stating that your While Controller condition is ${__jexl3("${model_name}" != "${modelnameresult}",)} and your screenshot shows different setup

I think it would be easier to go for Regular Expression Extractor instead.

8
  • Why regular expression should be used in this case? Commented Feb 24, 2022 at 12:14
  • I have tried both , same failed result. ${__jexl3("${model_name}" != "${modelnameresult}",)} and ${__jexl3("${model_name}" != "$modelnameresult",)} Commented Feb 24, 2022 at 12:26
  • model_name_18=Model-Corpus-JMeter2-0001-v1-8k is captured in debug sampler. what should be the while condition to handle it? Commented Feb 24, 2022 at 14:36
  • Theoretically ${__jexl3("${model_name_18}" != "${modelnameresult}",)}, however I repeat, there might be a better way to wait until the desired value is in the response
    – Dmitri T
    Commented Feb 24, 2022 at 14:41
  • right, seems I get the result I wanted when set the json extractor match no. to -1, all model_name returned but the specific one has model_name_xx numbering append behind, can I just find a way by modifying the while condition to match it? ${__jexl3("${model_name}" <= maybe this part Commented Feb 24, 2022 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.