Skip to content

Instantly share code, notes, and snippets.

@infomaven
Created November 5, 2014 08:36
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save infomaven/7fc690e051e1b7e412cd to your computer and use it in GitHub Desktop.
Enables user to select between different execution profiles from the same Gatling Simulation class file
val httpProtocol = http.baseURL("http://localhost:8000")
case class TestSetup(repeat: Int, users: InjectionStep, label: String) // <-- config holder
val sequentialUserTest = TestSetup(repeat = 100, atOnce(1 user), "sequential 1 user")
val oneUserPer4sTest = TestSetup(repeat = 2, constantRate(0.25 userPerSec).during(5 minutes), "1 usr/4s, 2 req / user")
val threeCentIn5Mins = TestSetup(repeat = 5, ramp(300).over(5 minute), "300 usr w/ 5 req in 5 mins")
val testSetUp = sequentialUserTest // <-- config selection (could be also done at runtime)
val scn = scenario(s"""<something> ${testSetUp.label}""")
.repeat(testSetUp.repeat) {
exec(http("<something ...>")
.get( """/index.html""")
...
)
}
setUp(scn.inject(testSetUp.users)).protocols(httpProtocol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment