0
votes

I am testing an application hosted in gcloud, to execute the test using jmeter I require OAuth token for respective User credentials. I am able to generate the token for one credentials, however I have not been able to find a way to generate them for more than one users.

If anyone has faced such problem or has any glimpse please let me know.

Note:

  1. I need a fresh token with every iteration since token expires in every 60 mins

  2. I am able to generate token manually to run the test

  3. I have tried auth/header manager for the process

  4. I have tried console auth code generation code as well

Above all generate auth code for a specific credential, wherein I have to keep the application active.

2
Please elaborate on what you have actually tried and where have you tried them. For example, when you say you have tried auth code generation code as well, is it on the JMeter's sampler or is it the IDE? Please add more details to respond better - M Navneet Krishna

2 Answers

0
votes

So you want to apply load to app backend using authenticated users.

If so, why don't you use

  1. CSV File to store your test credentials

  2. Use JMeter's CSV Config to read those credentials

  3. once only controller for authentication, extract access_token and refresh_token

  4. Use tokens to make calls to your backend

If you need to run loadtest / soak test for longer than one hour you can use if controller to verify the token validity and renew the token if necessary.

Hope this helps.

0
votes

If you need to refresh the token each 60 minutes it makes sense to create a separate Thread Group which will be executing a token refresh request each 60 minutes.

The token can be passed to the main Thread Group using __setProperty() function, you can make the token value thread-specific by combining it with __threadNum() function like:

  1. In "token" thread group:

    ${__setProperty(token_${__threadNum},${token},)}
    
  2. In "main" thread group you can read the value using __P() function:

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

Demo:

enter image description here

More information: Knit One Pearl Two: How to Use Variables in Different Thread Groups