How to update simulation "after" they've been instantiated?


I have a requirement to pass in a new OAUTH access token as part of my scenario simulation. We store that and other parameters in a JSON file that I read in with the feed() function of the scenario().

However, the token lasts for only 5 minutes and I’d like to refresh it so that the tests will continue to run without being blocked and getting 401 http status codes from the services that I’m trying to reach.

I was hoping that there was a way to modify some property that would allow the instantiated Simulation to realize that it needs to fetch the access token again from the file. The problem is, once the scenario is created there’s no need to recreate it. How do others get around such a problem?

Thank you for you advice on this, Bill

Assuming your scenario loops, at the head of the loop, inspect the token and test if it is expired. If it is, refresh it. You can make the requests silent so they don’t count towards your reports, too.