0

I have tested this Json extractor - JSON path expression to extract the GET response's model_name which value matched previous POST data.

POST data:

"model_name": "Model-Test-${variable}-${counter}"

GET response:

{
    "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": "Model-Test-2022-02-17T06106147-v1-8k",
            "status": "ok"
        }
    ]
}

JSON path expression at JSON extractor:

$..valid_model_list[?(@.model_name =~ /.*Model-Corpus-JMeter2-0001-v1-8k/i)]

and while condition : {__jexl3("${model_name_matchNr}" != "1",)}

The result is good that, while controller exit when Model-Corpus-JMeter2-0001-v1-8k is found in response.

I need to change the JSON path expression to use variables because variables were being used in the POST requests to make sure the unique value is being POST.

What is the correct syntax to replace Model-Corpus-JMeter2-0001-v1-8k to Model-Test-${variable}-${counter}-v1-8k?

**followings were tried, debug sampler doesn't return result: model_name= **

$..valid_model_list[?(@.model_name =~ /.*"${Model-Test-${variable}-${counter}-v1-8k}"/i)]

tried also store the Model-Test-${variable}-0001-v1-8k as user defined variable modelnameresult then set it at JsonPath Expression. Not working.

$..valid_model_list[?(@.model_name == "${__V(${modelnameresult})})]

Updated as per below suggestion: while controller exit successfully when using dummy sampler. once I use the actual HTTP request to POST data with variable then while loop does not exit, the result at debug sampler is always 'modelnameresult_matchNr=0'

enter image description here

enter image description here

1 Answer 1

2

It's possible to use JMeter Variables (or functions) in JSON Extractor JsonPath expressions, your syntax is simply incorrect (you can check it yourself using Debug Sampler)

My expectation is that you should be something like:

$..valid_model_list[?(@.model_name =~ /.*Model-Corpus-${variable}-${counter}-v1-8k/i)]

Demo:

enter image description here

0

Your Answer

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

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