I have my Gatling scenario set up and now I want to configure a simulation with fixed number of users for specific period of time - number of users should initially be increased gradually to specific value and then kept there by adding new as required as users finish.
I specifically don't want to use constantUsersPerSec
(which injects users at a constant rate) but something like .throttle(reachUsers(100) in rampUpTime, holdFor(10 minute))
which should inject users when required.
Simulation is the description of the load test written in the script. It can be written in Java, Scala, or Kotlin. Simulation scripts consist of scenarios, HTTP configurations and user loads, etc.Simulation is the parent class your tests must extend so Gatling can launch them.
Various keywords are used to specify this statement in Gatling Simulations: As well as several other loops. Gatling Simulations are written using the Scala programming language but use a dedicated DSL. You must use specific DSL components like the .forEach () or .doIfOrElse () for loops and conditions instead of native if or foreach expressions.
They are substituted, because the parameters have the same name. 7. Gatling Load Simulation Design So far all of our Gatling scripts have just been running with a single user. This is fine for debugging and script development purposes, but eventually we will want to config our scripts to run with many users.
The third and final part of the Gatling script is the Load Scenario. This is where we set the load profile (such as the number of virtual users, how long to run for etc.) for our Gatling test. Each of the virtual users will execute the scenario that we defined in part 2 above. Here, we are simply setting up a single user with a single iteration:
If it's still relevant: Gatling supports a throttle
method pretty much as you outlined it. You can use the following building blocks (taken from the docs):
reachRps(target) in (duration)
: target a throughput with a ramp over a given duration.
jumpToRps(target)
: jump immediately to a given targeted throughput.
holdFor(duration)
: hold the current throughput for a given duration.
So a modified example for your use case could look something like this:
setUp(scn.inject(constantUsersPerSec(100) during(10 minutes))).throttle(
reachRps(100) in (1 minute),
holdFor(9 minute)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With