Pause does not pause after the action?

Hi,

Recentl, I’ve been working on the performance test with Gatling.
And get confused about the pause clause, I’d really appreciate if any one can explain to me.

According to the definition of Pause:

“When a user sees a page he/she often reads what is shown and then chooses to click on another link. To reproduce this behavior, the pause method is used.”

My understanding is that: the users do one thing, then wait for a while , and do other things.
But according to my test, clearly it is not.

Example 1:

scenario("Basic Test")
  .exec(http("Post data")
   ...
  )
  .pause(5)

I use constantUsersPerSec(1)and during 60 seconds.

I think this will do a request and wait for 5 seconds, so in total it should be 12 request.
But in fact, there are 60 request.
To make it 5 seconds/second, I have to make the constantUsersPerSec(0.2).

**Example 2:**
scenario("Basic Test")
  .exec(http("Post data")
   ...
  )
  .pause(5)
  .exec(http("Get data"))
  .pause(5)

 
And in this example, I chained two actions together(action 2 has the same configuration constantUserPersec(1) as action 1). 
What I expected is: action1 -> 5 seconds -> action2-> 5 seconds-> action1->.....
And its not. 

Hope my description is clear enough. 
Thanks in advance. 

Figured it out.
I think the pause should be used between two actions, so the first one is not valid.
For the second one, my understanding is right.
But there are something wrong in my code, so it’s not working as expected.

Seems like I’m having a similar issue, were you able to figure it out and configure?

Hi, Tian.

You are confused about how the pause in the scenarios work, and how users are injected in your simulation. Let me explain:

Scenarios describe what ONE USER will do. So in your Example 2 your user will execute the Post Data step, wait for 5 seconds, then perform the Get Data step, to finally wait for another 5 seconds before doing anything else.
This makes your final pause(5) in the Get Data step irrelevant and you should eliminate it, as it will keep that user’s session open for no reason.

Your simulation as you inject ‘constantUsersPerSec(1)’ will create a new user each second, and each one of them will execute your Example 2 scenario independently of what other users are doing at any time. So that you end up having 60 users, one being created each seconds is what it is expected from ‘constanUsersPerSec(1)’ during 60 seconds.

Take a look at injections in Gatling’s documentation: https://gatling.io/docs/2.3/general/simulation_setup/#injection

You may want to try this combination for the users injection at your simulation:

nothingFor(5),
atOnceUsers(1),

nothingFor(5),
atOnceUsers(1),

nothingFor(5),
atOnceUsers(1),

nothingFor(5),
atOnceUsers(1)

This repeated as many times as you need.

I once needed to do something like this and wanted to use a loop, but didn’t find any for simulations in Gatling and requested it here (https://groups.google.com/forum/#!topic/gatling/AptfZSBsb68). Maybe you can support the request too.

Hope it helps!