JMeter JSR223 Postprocessor not updating User Parameter -
i have http sampler yields json string. parse json fragment using groovy jsonslurper update userparameter pollover:
import groovy.json.jsonslurper def jsonslurper = new jsonslurper() def response = jsonslurper.parsetext(prev.getresponsedataasstring()) def iserror = response.response.iserror def error = iserror ? "true":"false" def data = response.response.data def pollover = data?.trim() || iserror log.info("response = " + response) log.info("iserror = " + iserror) log.info("error = " + error) log.info("data = " + data) log.info("pollover = " + pollover) vars.put("pollover", pollover ? "true":"false") vars.put("data", data) vars.put("error", error)
unfortunately user parameter pollover never updated, although log groovy postprocessor show has right value:
2017-09-13 13:03:54,296 info o.a.j.e.jsr223postprocessor: response = [response:[version:1505333033161, data:138bdb6e-f0e9-48c0-8dd6-5bb14154d816, starttime:1505333033161, endtime:1505333033264, service, iserror:false, operationidlist:[2ca8719c-152c-4baa-8cfc-8ec1022cdc09], progress: created successfully, rootid:570ef302-89a2-4bc1-bd1a-4d06fba306a0, id:570ef302-89a2-4bc1-bd1a-4d06fba306a0], version:1.0] 2017-09-13 13:03:54,296 info o.a.j.e.jsr223postprocessor: iserror = false 2017-09-13 13:03:54,296 info o.a.j.e.jsr223postprocessor: error = false 2017-09-13 13:03:54,296 info o.a.j.e.jsr223postprocessor: data = 138bdb6e-f0e9-48c0-8dd6-5bb14154d816 2017-09-13 13:03:54,296 info o.a.j.e.jsr223postprocessor: pollover = true
if define pollover user defined variable, works fine. of course, need x distinct distinct threads , hence prefer use user parameters opposed udv.
is there gotcha here missing? can not update user parameter using vars.put(...) in jsr223 groovy postprocessor?
here while controller termination determined udv "pollover" (pollover defined in udv section "create site parameters"): [while controller depending on udv][3]
here postprocessor updates udv pollover make controller terminate: [enter image description here][4]
thanx,
r
user parameters pre-processor runs before samplers in scope. don't provide screenshot of test plan cannot tell sampler impacts, runs before sampler , erases value stores in variables.
for use case, define user parameters child of first sampler in thread group scope not erase value computed jsr223 postprocessor
see:
from comment, seems answer ok, fix it, add before while controller test action :
- pause mode , sleep 0
move inside user parameter element runs once initialize pollover.
i use test action pause = 0 avoid generating useless sampleresult. have used debug sampler also.
the main problem had, explained user parameter scope large applied requests overwriting value post processor updated.
Comments
Post a Comment