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'