-
Senior Software Engineer
-
Writing server-side code
-
Java Meetup Vienna co-organizer
-
Apache Software Foundation member
-
Currently working at Erste Bank Austria
-
Performance testing framework
-
Tests are written in in Scala
-
Developer-centric test tool
-
Development started in 2010
-
Gatling 3.0.1 released now
-
Since V3 there are two license models - free & commercial.
-
As you know some guys have a strong opinion about OSS
-
Gatling Open Source is under ASL 2.0
-
Gatling FrontLine is the enterprise edition
-
Annual license or "pay as you go"
-
Web-based,
-
More bells & whistle
-
Real-time reporting
-
-
Supports HTTP 1.1/2.0 & JMS protocol
-
Response validation
-
Regular expressions
-
XPath & JSONPath
-
CSS selectors
-
-
Provides Domain Specific Language (DSL)
-
Uses asynchronous non-blocking HTTP client
-
Integrates with Maven, SBT & Gradle
-
Test data feeders CSV, JSON, JDBC, Redis
-
Management-friendly HTML reports
-
No more 1:1 mapping between virtual users and worker threads.
-
Want to write test code in your IDE?
-
Need some integration & performance tests?
-
Want to run those test on your CI server?
-
Do you care about reviews and version control?
-
Import the Maven project into your IDE
-
Write and debug Scala code there
-
Execute Gatling tests on the command line
-
Simple CI integration using Maven
-
The official Gatling distributable is not suited for development.
-
The Gatling Maven archetype project does not use Maven Gatling plugin.
-
You can also use SBT & Gradle if you know your way around.
-
Parameter | Value |
---|---|
Main Class |
Engine |
VM Options |
-Dgatling.core.simulationClass=XXX |
-
You need to tell IntelliJ which Gatling tests to execute ….
mvn -Dgatling.simulationClass=computerdatabase.BasicSimulation gatling:test
-
Start Gatling from the Maven command line.
-
Please note that different system properties are used!!!
-
Perfect way to integrate with Jenkins
package postman
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class HelloWorldSimulation extends Simulation {
val httpProtocol = http.baseUrl("https://postman-echo.com")
val scn = scenario("Hello World")
.exec(http("GET").get("/get?msg=Hello%20World"))
setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))
}
-
Script setup
-
Common HTTP configuration
-
Scenario & load simulation setup
-
Load simulation text report
-
Creating Gatling scripts
package postman
import io.gatling.core.Predef._
import io.gatling.http.Predef._
class PostmanSimulation extends Simulation {
-
Gatling tests are deriving from
Simulation
val httpProtocol = http
.baseUrl("https://postman-echo.com")
.acceptHeader("text/html,application/xhtml+xml,;q=0.9,*/*;q=0.8")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.5")
.userAgentHeader("Gatling/3.0.0")
val scn = scenario("Postman")
.exec(http("GET")
.get("/get?msg=Hello%20World")
.check(bodyBytes.transform(_.length > 200).is(true))
)
.exec(http("POST")
.post("/post")
.formParam("""foo""", """bar""")
.check(status in (200, 201))
.check(bodyBytes.exists)
)
setUp(
scn.inject(
atOnceUsers(10) // (1)
).protocols(httpConf)
)
-
Injects a given number of users at once
setUp(
scn.inject(
rampUsers(10) over(5 seconds) // (1)
).protocols(httpConf)
)
-
Start 10 user within 5 seconds ⇒ 10 users
setUp(
scn.inject(
constantUsersPerSec(20) during(15 seconds) // (1)
).protocols(httpConf)
)
-
Start 20 users / second for 15 seconds ⇒ 300 users
setUp(
scn.inject(
heavisideUsers(1000) over(20 seconds) // (1)
).protocols(httpConf)
)
-
Create 1.000 users in 20 seconds using Heaviside step function
setUp(scn)
.assertions(global.responseTime.max.lt(100)) // (1)
-
Max response time of all requests is less than 100 ms
=============================================================
2018-11-16 20:43:51 2s elapsed
---- Requests -----------------------------------------------
> Global (OK=2 KO=0 )
> GET (OK=1 KO=0 )
> POST (OK=1 KO=0 )
---- Postman ------------------------------------------------
[#######################################################]100%
waiting: 0 / active: 0 / done: 1
=============================================================
---- Global Information -------------------------------------
> request count 2 (OK=2 KO=0 )
> min response time 118 (OK=118 KO=- )
> max response time 604 (OK=604 KO=- )
> mean response time 361 (OK=361 KO=- )
> std deviation 243 (OK=243 KO=- )
> response time 50th percentile 361 (OK=361 KO=- )
> response time 75th percentile 483 (OK=483 KO=- )
> response time 95th percentile 580 (OK=580 KO=- )
> response time 99th percentile 599 (OK=599 KO=- )
> mean requests/sec 2 (OK=2 KO=- )
---- Response Time Distribution -----------------------------
> t < 800 ms 2 (100%)
> 800 ms < t < 1200 ms 0 ( 0%)
> t > 1200 ms 0 ( 0%)
> failed 0 ( 0%)
=============================================================
-
Gatling Web Proxy Recorder
-
Start from the scratch
-
More initial work
-
Clean test code
-
-
Import HTTP Archive Format
-
Since I’m testing REST APIs I’m crafting my Gatling scripts from the documentation.
val httpConf = http
.baseURL("http://computer-database.gatling.io") // (1)
.acceptHeader("text/html,application/xhtml+xml,application/xml")
.doNotTrackHeader("1")
.acceptLanguageHeader("en-US,en;q=0.5")
.acceptEncodingHeader("gzip, deflate")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0)")
-
Need to support staging environments?
-
You might start writing your test hitting you local box or DEV environment.
-
later you want to switch to FAT, UAT & PROD.
val feeder = csv("users.csv").random // (1)
-
Different users / passwords for staging environments?
setUp(
users.inject(rampUsers(10) over (10 seconds)), // (1)
admins.inject(rampUsers(2) over (10 seconds))
).protocols(httpConf)
-
Different load for staging environments?
-
Your load testing environment might be a lot smaller than PROD.
Http(getURL("identity", "oauth/token"))
.postForm(Seq(
"scope" -> identityScope, // (1)
"grant_type" -> identityGranType,
"client_id" -> identityClientId,
"client_secret" -> identityClientSecret,
"resource" -> identityResource
))
-
Tons of configurable properties?
-
How to pass the configuration properties which might be dependent on your staging environment?
-
System properties
-
Maven profiles
-
Custom Scala class
-
Unhappy with those approaches
-
I came up with Gatling Blueprint Project
-
Staging & multi-tenant support
-
Hierarchical configuration & file resolver
-
Pretty-printing & filtering of JSON responses
-
Stand-alone Gatling distribution
-
Implementing some best practices
-
Gatling Blueprint Project - a recipe of how to do things with Gatling
-
Use it like a cooking recipe - try it and change it to your personal taste
Tenant |
The tenant to test (AT, CZ, SK) |
Application |
Application to simulate (web, mobile) |
Site |
Staging site to be tested (dev, prod) |
Scope |
Scope of test (smoke, performance) |
-
Erste Bank Austria,
-
Česká spořitelna,
-
Slovenská sporiteľňa
-
Banca Comercială Română
-
I was part of George International Team for 2 years
-
George is Erste Bank Austria’s Online Banking
-
It became a group-wide solution for Online Banking
-
Many moving parts & staging sites
-
Gatling for automated integration tests
-
Internal performance testing
-
Continuous performance testing?
-
Other teams use JMeter & Neoload
-
Continuous performance testing is a cultural problem not a technical
-
Integration tests across tenants & sites
-
Developer driven performance testing
-
Elastic Search server migration & tuning
-
Desaster recovery tests
-
Detecting changes between releases
-
Gatling’s DSL is elegant & powerful
-
Programming power at your finger tips
-
-
Scala & DSL learning curve
-
Requires solid development skills
-
-
Works on Windows, Linux & OS X
-
Developer-friendly tool
-
Code only, IDE support & refactoring
-
Integrates nicely into your build process
-
Do you need to onboard your test team?