1
votes

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:

  1. create defined variable STATUS_OK

    enter image description here

  2. Create regular expressions extractor under bid request to get response code enter image description here:

  3. Add If controller and insert win request under that controller enter image description here:

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 structureenter image description here:

  • bid requests - is CSV Data set config wit random jsons for each bid request (did like mentioned here)
  • thread - it's a thread with 200 users and 1 loop
  • bid - post request, for body I'm using one of json files ${__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.
  • if bid made - if controller discussed here
  • win - get request, where URL queries are different depends on bid response (using Json extractors). Url looks like: win?auctionId=${AUCTIONID}&bidId=${BIDID}&impId=${IMPRESSIONID}&seatId=${SEAT}&price=${__javaScript((Math.random()* (4 - 1)+1).toFixed(4);)}&cur=${CUR}&adId=${ADID}
2

2 Answers

3
votes

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}")}
1
votes

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')),)}

JMeter Groovy Previous Request Status

More information: Apache Groovy - Why and How You Should Use It