How session attribute is defined per each scenario running ?

I have the following scenario:

Hi Sharon,

Where is this id coming from? A previous request?

If you just need to get a single id and then to use it with all you users you can:

  • Know it before the test and use it as a system props (or whatever way to pass it, a feeder, a val etc.)
  • maybe just fetch it in a before block
  • or use a thread safe structure to fetch it with one user and then use it with the other users.

However, the code you are showing can be improved :

Hi,
This “id” is supposed to be generated randomly and each random value should be used per user (per scenario, per method 1 + method 2).
How should I do it ?
I want to run scenario with multiple methods (chains) and assign random id for each user in the scenario.
In addition, I use randomSwitch because the methods should be called in some relation to the total requests per second (in the above example is 50%-50%).
Please let me know , if i miss something, or something should be done differently.
Thanks

בתאריך יום חמישי, 25 באוקטובר 2018 בשעה 18:35:43 UTC+3, מאת Alexandre CHAOUAT:

That’s the opposite of what you asked the first time.

Just use an exec block to generate an id and save it to the session. Each of the user will pass through this exec block and generate their id.

And don’t forget to use the Gatling expression language if you want to use variable coming from the session in the Gatling DSL. https://gatling.io/docs/3.0/session/expression_el/

but randomSwitch doesn’t execute just one method and move to the execution of the next user?
The second time that each user will be executed will be with different random value, isn’t it?

בתאריך יום שישי, 26 באוקטובר 2018 בשעה 16:17:36 UTC+3, מאת Alexandre CHAOUAT: