Installation
- Pre-reqsJava 8/11 + Scala 2.12
- Linux$GATLING_HOME/bin/gatling.sh
- Windows%GATLING_HOME%\bin\gatling.bat
- Recorderbin/recorder.sh
Scenario Definition
- scenarioTest name to be reported
- execExecution step
- groupGroup requests together
- pauseSet a fix or random delay
- paceSlows actions to achieve pace
- rendezvousPause users until all reach point
- repeatIterate N times
- duringIterate for duration
- asLongAsIterate while condition holds
- foreachIterate each element
- foreverIterate continuously
- doIfExecute when condition met
HTTP Protocol
- httpDeclare HTTP request
- getHTTP GET
- postHTTP POST
- putHTTP PUT
- deleteHTTP DELETE
- headerHTTP Header
- bodyHTTP Body
Feeders (Data Sources)
- csvCSV file source
- jsonFileJSON file source
- jdbcFeederDatabase via JDBC
- randomRandom values
- circularCycle then repeat
- shuffleShuffled order
Injection Steps
- atOnceUsersAll users at once
- rampUsersUsers over time
- constantUsersPerSecFixed rate
- rampUsersPerSecRate ramp
- nothingForPause injection
Assertions
- globalStats from all requests
- forAllStats per request
- responseTimeResponse time (ms)
- requestsPerSecThroughput
- successfulRequestsSuccess count
- failedRequestsFailure count
Full Simulation Example
class BasicSimulation extends Simulation {
val httpProtocol = http
.baseUrl("https://api.example.com")
.acceptHeader("application/json")
val scn = scenario("Load Test")
.exec(http("Get Users").get("/users"))
.pause(1)
.exec(http("Get User").get("/users/1"))
setUp(
scn.inject(rampUsers(100).during(60))
).protocols(httpProtocol)
}
Simulation Config
- pausesConfigure pauses
- maxDurationMax test duration
- throttleLimit throughput
- protocolsSet protocol config
- assertionsDefine assertions
Tips & Hints
Recorder
Use Gatling recorder to aid script creation
Encoding
Default encoding is UTF-8
Config
gatling.conf contains configuration values