I have a Gatling script with the following simulation which contain a few scenarios each of the scenarios contains an injection profile that is duplicated.
setUp(
script.create_learner_scenario.inject(
nothingFor(nothingForDuration minutes),
rampUsersPerSec(1).to(userCount).during(testRampUpDuration minutes),
constantUsersPerSec(UserCount).during(testDuration minutes),
rampUsersPerSec(userCount).to(1).during(testRampDownDuration minutes)
),
script.put_learner_scenario.inject(
nothingFor(nothingForDuration minutes),
rampUsersPerSec(1).to(userCount).during(testRampUpDuration minutes),
constantUsersPerSec(userCount).during(testDuration minutes),
rampUsersPerSec(userCount).to(1).during(testRampDownDuration minutes)
),
script.patch_learner_scenario.inject(
nothingFor(nothingForDuration minutes),
rampUsersPerSec(1).to(userCount).during(testRampUpDuration minutes),
constantUsersPerSec(userCount).during(testDuration minutes),
rampUsersPerSec(userCount).to(1).during(testRampDownDuration minutes)
),
script.get_learner_scenario.inject(
nothingFor(nothingForDuration minutes),
rampUsersPerSec(1).to(userCount).during(testRampUpDuration minutes),
constantUsersPerSec(userCount).during(testDuration minutes),
rampUsersPerSec(userCount).to(1).during(testRampDownDuration minutes)
)
).protocols(httpConf)
Is it possible to have the injection profile in a separate function so that I can reuse it in each of the scenarios
nothingFor(nothingForDuration minutes),
rampUsersPerSec(1).to(userCount).during(testRampUpDuration minutes),
constantUsersPerSec(UserCount).during(testDuration minutes),
rampUsersPerSec(userCount).to(1).during(testRampDownDuration minutes)
You can store your different load profiles in List
:
val loadProfile = List(
constantUsersPerSec(5) during (5 minutes)
)
val anotherLoadProfile = List(
rampUsersPerSec(0) to 20 during(3 minutes),
nothingFor(30 seconds)
)
setUp(
scn.inject(
loadProfile
).protocols(protocol)
)