Similar to other questions that are either old or unanswered (in particular, Passing session variables between 2 scenarios), is it possible to save the result of one scenario and use it as a session variable in a subsequent scenario?
The main use case I have in mind is getting a single OAuth token to use for many requests in a subsequent scenario. I can work around with a ConcurrentHashMap but it would be nice to know if there’s a better way of doing this with Gatling features.
session is for one virtual user. A virtual user is for a scenario.
So, there is no way a session variable is given to another scenario, and in Gatling terms, there is no sense to that.
In the other hand, you may have global variables (if you don’t use Gatling Enterprise with multiple injectors) that every scenario can read (you will be in charge to manage the read of that)
Another way to pass information will be to write in a file that is read as feeder by another scenario.
Again, in terms of Gatling your question makes no sense, we have in one hand the OAuth token that should identify 1 user and in the other hand many request from another scenario that means different virtual users.
Personally, I would craft a scenario that acquire a OAuth token to store in the user session then do a loop to have many requests.
Do that make sense in your test?