0
votes

There is an LoginAPI which will generate a bearer token and same token is used as part of header in subsequent apis(API-1, API-2, API-3).

LoginAPI is called under SetupThreadGroup, which will write the tokens to file OtherAPIs(API-1,API-2,API-3 are called in a seperate thread group which will read tokens and use it in API's) Currently, token expiration time is 30 minutes. If we execute load test for 1 hour then post 30 minutes test, all the request gets failed with authentication issue(As tokens have expired)

Can any one suggest a solution to handle re-generation of tokens when expired and re-use the same in load test. This way, i can run test for a longer duration.

1

1 Answers

0
votes
  1. Switch from setUp Thread Group for "LoginAPI" to normal Thread Group and configure it to run either desired number of iterations or forever

  2. Add Flow Control Action sampler to the end of the "LoginAPI" thread group and configure it to "sleep" for i.e. 25 minutes

    enter image description here

    This way first thread group will execute the Login generating or refreshing the token each 25 minutes so "Other" thread group should be safe

If you need to pass the token from LoginAPI to OtherAPIs you can use either __setProperty() and __P() functions combination or Inter-Thread Communication Plugin