Gatling protocol that allows running load test using commandline commands.
Gatling version 3.3.0
- Copy the contents of the commandprotocol under your gatling simulations folder.
- Import the protocol in your scenario using
import commandprotocol.Predef._
- Create a new command protocol as below:
val commandProtocol = script
.set()
- Use the script protocol in your scenario
val scn = scenario("CommandSimulation")
.exec((session: Session) => {
session.set("path", "")
})
.pause(5)
//STEP 1. Clone a random repo into ${clonePath}
.exec((session: Session) => {
val command = "mkdir /tmp/commandtest"
session.set("command", command)
})
.exec(command("CreateDirectory").run())
.pause(5)
//STEP 1. Clone a random repo into ${clonePath}
.exec((session: Session) => {
val command = "rm -rf /tmp/commandtest"
session.set("command", command)
})
.exec(command("RemoveDirectory").run())
.pause(5)
setUp(
scn.inject(atOnceUsers(1))
).protocols(commandProtocol)
}
A simple test has been created to showcase the usage of this protocol. This scenario will create a directory under /tmp/commandtest
and then will remove it in the next command. Under test/bin Run ./run-test.sh -s commandTest.TestSimulation
Commands that return a non zero code will be marked as KO.