Reputation: 5540
In my test plan I have 2 endpoints bid
and win
. And if bid
endpoint return status 200 (it can also return 204, but I need only 200 so I can't use ${JMeterThread.last_sample_ok}
) I need to run win
endpoint.
I did:
create defined variable STATUS_OK
Create regular expressions extractor under bid
request to get response code :
Add If controller
and insert win
request under that controller :
But if controller
condition not working, Jmeter never run win
request.
Any idea why it's not working? or maybe have I can debug it? I would be grateful for any help!!!
Updated including test plan structure:
${__FileToString(/home/user/Downloads/jmeter/jsons/${__eval(${JSON_FILE})}.txt,,)}
.
Also bid request include currency, bidid etc. it's Json
extractors, I'm using that data to generate correct win URL for
each bid.win?auctionId=${AUCTIONID}&bidId=${BIDID}&impId=${IMPRESSIONID}&seatId=${SEAT}&price=${__javaScript((Math.random()* (4 - 1)+1).toFixed(4);)}&cur=${CUR}&adId=${ADID}
Upvotes: 1
Views: 2555
Reputation: 168072
You need to surround JMeter Variables references with quotation marks like:
"${BID_STATUS}" == "${STATUS_OK}"
Alternatively (better) you can get rid of this Regular Expression Extractor and switch If Controller's condition to use __groovy() function like:
${__groovy(prev.getResponseCode().equals(vars.get('STATUS_OK')),)}
More information: Apache Groovy - Why and How You Should Use It
Upvotes: 2
Reputation: 58772
For If Controller You should use __groovy or __jexl3 function instead
Interpret Condition as Variable Expression? If this is selected, then the condition must be an expression that evaluates to "true" (case is ignored). For example, ${FOUND} or ${__jexl3(${VAR} > 100)}. Unlike the JavaScript case, the condition is only checked to see if it matches "true" (case is ignored). Checking this and using __jexl3 or __groovy function in Condition is advised for performances
In your case use
${__groovy(vars.get("BID_STATUS") == vars.get("STATUS_OK") )}
Or
${__jexl3("${BID_STATUS}" == "${STATUS_OK}")}
Upvotes: 3