Reputation: 89
I am working on a performance testing scenario using JMeter, and I need to obtain a unique token for each request within a Thread Group(s). The token is coming from an HTTP request. So for example, if we are sending 100 requests need to obtain 100 unique tokens.
I have an HTTP Request Sampler that retrieves the token. I have another HTTP Request Sampler that uses the token and sends the request.
My current doubt is how to make sure when each thread is executing the flow, it should always execute the Token HTTP Request Sampler first and get the token.
Can anybody tell me how can I achieve something like this? What's the best practice? Previously I was using Setup Thread Group in Global Level outside of all the Thread Groups and used a single token for all Thread Groups and Requests. But now need a unique token per each request.
Thanks in advance!
Upvotes: 0
Views: 274
Reputation: 168147
JMeter executes Samplers upside down so it's sufficient to place the request which gets the token above the request which uses the token.
If you plan to run the "token" request only during first iteration of the Thread Group you can put it under the Once Only Controller
The approach with setUp Thread Group is also viable, but make sure to use unique properties names, i.e. use __threadNum() function as the property postfix.
More information: Using JMeter Variables With Multiple Thread Groups
Upvotes: 0