Search code examples
jmetertokenthread-synchronization

Jmeter - running multiple threads using different author token


I have created a thread with three steps to:

  1. Access token request: it generates a token to be used in step three. This token is stored in a property

    ${__setProperty(accessToken,${accessToken})}

  2. Logon Get request to hit a url

  3. Logon Post request, pass some data to the url and I have set the Authorisation header using the Bearer + accessToken (the one generated in first step.

Running a single thread it works, perfect; but when I increase the number of threads, the 3 steps are not running in sequence, maybe I have some Access token before the first Logon Post and I see the token this one is using is not the token generated in the first step, it is the last one generated.

If I set a rump time longer of the total execution time it works, but then I cannot run several threads on parallel.

How can I configure the script to run the threads using the correspondent token generated in step 1 in each Post? How can I different properties or variables to store the token of every thread and use them?

Thanks.


Solution

  • Your issue is that you are mixing Variables and Properties.

    In summary, as per functions reference:

    • Variables are per Thread
    • Properties are shared accross Threads

    So don't use setProperty, just use ${accessToken}