Search code examples
performancejmeterperformance-testingjmeter-pluginsjmeter-5.0

How can I configure Jmeter such that it hits two different tokens, one after the other, then after some period of time it hits only the second token?


I have to run a soak test for 24 hours with two tokens- GET and Validate

Here I have to hit Validate token continuously for 24 hours using the same access token which I get from the GET token.

The access token expires every 12 hours, so my approach is to hit the GET token once at the start then use the same token in VALIDATE token for the next 12 hours, then again I want to hit GET token after 11 hours 55 minutes , and use this access token for the next 12 hour hits for Validating it.

I tried creating 4 thread groups in Jmeter, where

In the first thread group I hit the GET token once, and use that GET token's access token to hit the validate token for the next 11 hours 55 minutes, again did the same for the next 2 thread groups, but it didn't work as expected

Please suggest if there are any other approaches to achieve this.


Solution

  • I think you could go for:

    1. 1st Thread Group which will be getting a token each 11 hours 55 minutes and converting it into a JMeter Property via __setProperty() function or JSR223 PostProcessor and Groovy script like `props.put('some-property-name', vars.get('variable-holding-the-token'))

      The "sleep" for 11 hours and 55 seconds can be created using Flow Control Action sampler

    2. 2nd Thread Group which will be using the token via __P() function like:

      ${__P(some-property-name,)}
      

    This way the request in 1st thread group will be repeated each 11 hours and 55 minutes so the token will not expire.

    More information: Using JMeter Variables With Multiple Thread Groups