Token renewall function to be run only one time during execution

Hello everyone. How are you?

I have a problem with my Gatling execution. We have a specific way of generating tokens for the user session. We first call a function outside the Gatling scenario to set up the Authorization header, and then I start the execution. The problem is that the token only lasts 10 minutes and I want to generate a new one during the execution.

I’ve tried multiple approaches, like calling the token function when I receive the 401 status code, but I always end up with the token being generated for all the 100 users, when instead I just want to run the function only ONE time.

Can anyone help me with that?

Hi @boxfreeman,

Welcome aboard!

@GeMi already created a full example for your use case:

Enjoy!

Cheers!

1 Like

Hello @sbrevet
Thank you very much! It worked perfectly here!
One thing is that my console output now has the other scenarios exits.
I was wondering if there is any way to hide the output of the scenario on the console or in the final metrics.
If there is no way to hide it, no worries.
Thanks again!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.