Inject multiple users with pause

I want to launch my scenario in a sequential manner to bring it closer to reality by executing the request 79 times with a variable pause between interval 1s and 5s.
Now i’m doing it in a classic way as follows (I repeat that by reaching 79 user)
inject users.PNG

how to do it in one line?
I need help please.

thank you in advance

Hi,

Are you sure it is a scenario (different users) or a request you want 79 times?

If you really want a scenario.
My scenario will have a pause with a min and a max before sending my request.
And the injection will have a constantUsersPerSec randomized

If you want a request sent randomly by the same user.
The simulation will inject once the user (with atOnceUsers(1))
The scenario will have the pause with a min and a max before the actual request in a loop.

Hope it helps.
Cheers!

Hello,
Thanks for your return.
I have a question to propose the difference between a user who will execute the request several times and each user executes the request is that there is a difference in response times with the two ways ?

Hello,

I would like to reopen this topic, as it was not actually answered, and I have similar (even simpler) situation.

My customer requires me to send couple of users (constant number) each 5 minutes during 4 hours. So my execution plan looks like:

                    atOnceUsers(13),
                    nothingFor(300),
                    atOnceUsers(13),
                    nothingFor(300)


and so on for 48 times… Is there any looping mechanism suitable in this context?

Best Regards,
Arek

You can check this Solution:

Hello Gerard,

d…n it, I have Your repo bookmarked since few months (and I recommend it widely) but somehow I missed this snippet… :face_exhaling:
It works like a charm!

Thanks a lot/dzięki serdeczne!
Arek

1 Like

Hi @ghazouani_nada,

Maybe.
As this is the first (and only) request for a given virtual user, it will have to find the ip (dns), then connect to the server (TLS) before sending the request.
If the same virtual user do that, it can reuse the already opened connection for subsequent requests.

Cheers!

maybe you have finished the task,
Here is my attempt in Scala Language in case someone needs it:

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class caseTestLoop extends Simulation {

  val httpProtocol = http
    .baseUrl("https://reqres.in")

  val scn = scenario("test")
    .exec(
      http("test")
        .get("/api/users?page=2")
    )

  val injectSeq = Seq.fill(3)(Seq(atOnceUsers(1), nothingFor(10 seconds))).flatten

  setUp(
    scn.inject(injectSeq)
      .protocols(httpProtocol)
  )
}

Cheers !