I´m working on a JMeter testplan which is meant to preformance-test a webservice. The main part of the whole testplan consists of two steps.
- Create one of these asset ID (via Post-request) - extracting asset ID by JSON extractor and setting variable using bean shell assertion ${__setProperty(assetId,${assetId})}
- Delete created asset by ID (Delete request) - ${__property(assetId)}
If I use a singlethreaded plan, everything works out as expected, but as soon as I use more than one thread, then assetId will have last thread value and remaining values will be missed out. Could you please let me know how I can access/store all assetId in delete call
CodePudding user response:
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.
You should use the variable name of your JSON extractor instead of creating a property to avoid sharing the variable between threads.
CodePudding user response:
You're overwriting the same property by each consecutive thread, you need to do something like:
In the first step change your code to:
props.put("assetId_" ctx.getThreadNum(), vars.get("assetId"));
In the second step use the __groovy() function to read the property value:
${__groovy(props.get("assetId_" ctx.getThreadNum()),)}
Also be aware that starting from JMeter 3.1 you're supposed to be using JSR223 Test Elements and Groovy language for scripting so consider migrating to JSR223 Assertion with Groovy.