Multiple objects under a single 'during'

I have the following objects as part of a scenario. Login, verification, flow and logout.
I want to run a test for 20 users(for example) for 10 minutes. I want all the 20 users to ramp up in the first 5 minutes and be in the system for the next 10 minutes. I want all 20 users to loop through verification and flow objects. In the last 5 minutes I want all the 20 users to execute the logout object.

1.I tried to create 2 scenarios like below. But did not know how to ramp down the users in the highlighted line below. I read some where that Gatling does not provide ramp down. Stephane told me that this is an incorrect way of defining scenarios.

val scn = scenario(“CoreScenarios”)

.during(2 minutes){

exec(Login.login, Verification.verification, Flow.flow,)

}

val scn1 = scenario(“Logout”).exec(Logout.logout)

setUp(

scn.inject(rampUsers(20) during (1 minutes)).protocols(httpProtocol)

.andThen(

scn1.inject(atOnceUsers(1)).protocols(httpProtocol))

)

  1. I tried to add .during{} to verification object. I know for the fact that verification object will run in a loop for the duration specified. But I want verification and flow objects together run in one single loop using ‘during’ and did not know how to achieve this?

I tried adding during{} outside of all the objects, but when I run the test, the objects are not getting recognized.

Hi,

First, we will let the code aside for now.

I will try to understand what you want to achieve.

I want to run a test for 20 users(for example) for 10 minutes. I want all the 20 users to ramp up in the first 5 minutes and be in the system for the next 10 minutes. I want all 20 users to loop through verification and flow objects. In the last 5 minutes I want all the 20 users to execute the logout object.

Ok, from this starting point, I will try to understand what 1 user should do:
Once started, your user should stay connected for 10 minutes and then logout. Is that correct?

In that case, a scenario (the actor script for one user) should look something like

When you arrive: login in the 5 first minutes
Make your stuff (and ensure that your stuff lasts 10 minutes)
Then logout in the last 5 minutes

So if all users start at the same time. For each user, we can define this “scenario”:

Pick a time between 0 and 5 minutes
Compute the remaining (5 minutes minus the picked time)
Wait for your picked time
Login
Wait for your remaining time
Begin your work (perhaps with a random wait time too)

Logout

From now, I think you should get the concept I try to invoke.

But, that stays a weird way to use gatling.

Gatling is meant to test a web server.
The real users don’t wait for each other to begin their work, or it is part of the usage of the application itself.

For instance, if each user can use the application independently, why do I have to wait for someone else?

On the other hand, if the application makes me wait and the browser checks every n seconds that other is ready, as a user, I interact with the web application, not directly with other users.
(example: a multiplayer game, when a game starts when enough players join)

Please, review what you really want to test.

Cheers!

Sebastien

Thank you so much for responding. I am sorry if I had meant that each of the user needs to wait for the other user to logon. That is not what I meant. I need all the 20 users to be ramped up in 10 minutes. Example user number 1 will login and will start performing verification and flow objects. User 2 will login next and will start performing verification and flow objects…goes on till the 20th user. All the 20 users will loop verification and flow objects during steady state (login will not be executed since 20 users are already in). In the last 5 minutes, each of the 20 users will execute logout object one after the other.

for one user, this is the scenario. user 1 logs in, execute verification and flow objects(in loop during steady state) and logs out.

Thanks
Siddharth

So, you answered your own question.

A user will perform a scenario. (login, during (time).exec (verification and flow objects), then logout)

val myScenario = scenario("My Scenario")
  .exec(Login.login)
  .during(10 minutes) {
    exec(Verification.verification, Flow.flow)
  }
  .exec(Logout.logout)

the injection profile should only inject your 20 users when you want.

val injectionTime = 5.minutes
val totalUsers = 20

val timeInSeconds = injectionTime.toSeconds
val usersPerSecond = totalUsers.toDouble / timeInSeconds 

setUp( myScenario.inject(constantUsersPerSec(usersPerSecond).during(injectionTime)))

Cheers!

Thank you so much! this worked!