0
votes

I have a post -processor with the below code.

import test.MFG
MFG mfgRepo = new MFG();
log.info("device {}","${deviceID}");
long crashTime= ${p1};
String deviceId1="${deviceID}";
log.info("the crashtime is {}",crashTime);

List<Map<String,Object>> dbItem = mfgRepo.getItemFromDB("TEST",deviceId1,crashTime);
log.info("The item is {}",dbItem.get(0).get("info"));

In the above the deviceID and p1 are variables that vary in each request e.g testdevice1,testdevice2... and p1 is a different timestamp. when these values are run in a postprocessor only the first request value is been processed in all the post-processor. what am I doing wrong? how can I implement the same validation in a while controller which would go and test if dbItem.get(0).get("info") is not null for each request made in a concurrency thread group. enter image description here

1

1 Answers

0
votes

As per JSR223 Sampler documentation

The JSR223 test elements have a feature (compilation) that can significantly increase performance. To benefit from this feature:

  • Use Script files instead of inlining them. This will make JMeter compile them if this feature is available on ScriptEngine and cache them.
  • Or Use Script Text and check Cache compiled script if available property.

When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters.

So change your:

  • ${deviceID}" to vars.get('deviceID')
  • ${p1} to vars.get('p1') as long
  • etc.

where vars is a shorthand for JMeterVariables class instance, see the JavaDoc for full description of available functions and properties and Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on using this and other JMeter API shorthands available for the JSR223 Test Elements