1
votes

We are using Jmeter 5.1.1 v to perform load testing, Our scenario is get 25 tokens from Setup thread group (Threads set to 25 with rampup 25 secs under SetUp Thread group), then having a normal Thread group which contains HTTP Sampler and in this Sampler need to pass those 25 tokens for each 1 thread hence this Thread Group contains configuration of 25 Threads with 25 Secs.

However when Run the test, 25 tokens been generated but only the last 25th token used for all threads (using the 25th token). Trying to get for each Thread should get one token value, if 2nd thread then 2nd token should be used.

Below is the Structure:

TestPlan 
--SetUp Thread Group - 25 Threads, 25 Secs
---HTTP Sampler - Gets the Token here using RegEx and Set the value as Property using Beanshell Assertion
O/P: Got 25 tokens generated, and set in the property value

--Thread Group - 25 Threads, 25 Secs
---HTTP Sampler - Get Token value as property
O/P: Only the 25th token been used for all 25 threads

EDIT

Tried answer and got error:

enter image description here

Error

2
Why using SetUp Thread Group? why not create token inside same thread group?user7294900
Thanks for reply, SeUp Thread group token generation request we do not want to consider for results analysis, we need to analyse performance of Normal Thread group sampler request only. The token sampler is the workaround we are using to generate token by hitting API.la1

2 Answers

2
votes

Create token inside same thread group, if you do not want to consider for results,

You can ignore token sampler by adding JSR223 PostProcessor with the line prev.setIgnore()

prev - (SampleResult) - gives access to the previous SampleResult

1
votes

Not knowing how do you pass the tokens between Thread Groups it's quite hard to tell what's wrong, a "blind shot": you're using a single JMeter Property which is being overwritten.

The solution is to make the token thread-specific, for example you can set it like:

props.put("token_" + (ctx.getThreadNum() + 1), vars.get("variable from regex here"));

and then read it using __P() function like:

${__P(token_${__threadNum},)}

Few more hints:

  1. You should be using the latest version of JMeter which is JMeter 5.3 as of now
  2. You should NOT be using Beanshell, consider using JSR223 Test Elements and Groovy language
  3. Passing data between threads (even if they're in different Thread Groups) is much easier with Inter-Thread Communication Plugin