How to execute the first request only once?

Hi,

I’m trying to run a scenario which has 2 requests

  • The first one authenticates the users through an API and gets a token. I want each user to do the first request only once.
  • The second one executes a GET throught another API.

Here’s the code of the scenario:

Here’s the code of the simulation:

Capture.PNG

When I execute the above simulation, I can see in the logs that each of the 2 requests are both executed 15 times. I’m expecting to have less “Get_token” executed than “Get_slot”.

I’ve read some documentation avout Gatling’s forever element, and I think it could do the work. But I would like to understand why this does not behave as I expect.

If both requests are executed 15 times, does it mean that:

  • 15 users are launched, and thus their session is empty at the beginning, so it’s normal they do the get_token ?
  • My “Doif” is not well written ?
  • Something else I’m missing ?
    In the Gatling report, I only see 2 actives users during the test (in average) (max 4). This is why I expect to see 4 “Get_token”, and not more.

Any help would be great, thank you in advance.

This e-mail and any attachment are confidential and intended solely for the use of the individual to whom it is addressed. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. Unauthorized publication, use, dissemination, forwarding, printing or copying of this e-mail and its associated attachments is strictly prohibited.

Let’s respect the environment together. Only print this message if necessary.

You mixed up 2 different concepts in gatling.

On one hand, we have a Scenario. A Scenario is actually like the script of an actor (as in a theater play) and describes what a user will do.
So, if you want a user to execute the first request once and the second request several times, you may define that in the scenario.

In another hand, we have a Simulation. A simulation is the description of the injection profile. (not only that, but it is what matters in our concern here).
In the simulation, you can describe the entrance of the different actors on the theater stage. When they begin to play their role.

To answer directly to your questions:

15 users are launched, and thus their session is empty at the beginning, so it’s normal they do the get_token ?

Indeed, you have one new user each second constantUsersPerSec(1) during 15 seconds during(15.seconds), so yes, the computation is correct.

My “Doif” is not well written ?

Syntactically correct, but as explained, a scenario is a fresh user. So always empty.

Something else I’m missing ?

The difference between Scenario and Simulation.

Is that more clear now?

Hope it helps
Cheers!

Capture.PNG

Hello Sébastien,

Thanks for your help. I got it.
So even if there are only up to 4 users on the “active users” curve, this is because each second, a new user is created and stopped after he’s done doing his requests ?
Let’s say the active users curve’s value is constantly 2 during 15 seconds => does it mean that 2 x 15s = 30 different users/threads are created during the test ?

It’s different than other load testing tools I’ve tried so far. (In which only 1 user would have been launched)

Again, thank you a lot :slight_smile:

Capture.PNG

Hello Sébastien,

Thanks for your help. I got it.
So even if there are only up to 4 users on the “active users” curve, this is because each second, a new user is created and stopped after he’s done doing his requests ?
Let’s say the active users curve’s value is constantly 2 during 15 seconds => does it mean that 2 x 15s = 30 different users/threads are created during the test ?

It’s different than other load testing tools I’ve tried so far. (In which only 1 user would have been launched)

Again, thank you a lot :slight_smile:

As the name suggests: “active users” are the count of users that are active (started but not ended) during the second.

The active users count depends on your injection profile (how many are started) but also on your scenario(s), as a user may take time to end (several requests and/or pauses, etc.).

So even if there are only up to 4 users on the “active users” curve, this is because each second, a new user is created and stopped after he’s done doing his requests ?

In your case, it seems so, yes!

Let’s say the active users curve’s value is constantly 2 during 15 seconds => does it mean that 2 x 15s = 30 different users/threads are created during the test ?

Only with the “active users” curve, we cannot affirm such things.

For instance:

  • 2 users injected once, but their scenario lasts more than 15 seconds.
  • 1 user with a scenario that lasts more than 15 seconds, and another injection of 15 users (each second) for a scenario less than a second.
  • 2 users injected each second and the (common) scenario lasts less than a second

For each different case, the “active users” graph will show the same thing: constantly 2 during 15 seconds.

Cheers!

Capture.PNG

Ok very clear ! Thank you a lot.

Cheers!
Terry