2. GATLING TO SHIFT LEFT
Why use Gatling?
Develop QA Perf Stage Production
2
Develop QA Perf Stage Production
3. 3
GATLING FOR DEVELOPERS
How to use Gatling?
• Compare to Jmeter, Locust, The Grinder, Intuit Tank, etc.
• Scala is a general-purpose programming language providing
support for functional programming and a strong static type
system. Designed to be concise, many of Scala's design
decisions aimed to address criticisms of Java.
• Gatling Cheat Sheet
4. val httpConf = http
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.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) Gecko/20100101
Firefox/16.0")
val google = scenario("Search for Game of Thrones on Google")
.exec(http("https://google.com/search?q=game+of+thrones")
.get("https://google.com/search?q=game+of+thrones"))
val yahoo = scenario("Search for Game of Thrones on Yahoo")
.exec(http("https://search.yahoo.com/search?p=game+of+thrones")
.get("https://search.yahoo.com/search?p=game+of+thrones"))
setUp(
google.inject(constantUsersPerSec(2) during(2 minutes)),
yahoo.inject(constantUsersPerSec(2) during(2 minutes))
).protocols(httpConf)
5. GATLING WITH MAVEN
Executing the test
5
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
</plugin>
mvn gatling:execute -Dgatling.simulationClass=<simulationName> -Denv=perf -Dpercent=10 -Dramp=15 -
Dduration=60
7. GATLING LOGGING, CHARTING
Fast Debugging for faster turnaround
7
>>>>>>>>>>>>>>>>>>>>>>>>>>
Request:https://google.com/search?q=game+of+thrones: KO status.find.in(200,304,201,202,203,204,205,206,207,208,209),
but actually found 404
=========================
HTTP request:
GET https://google.com/searchz?q=game+of+thrones
headers=Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8DNT: 1Accept-Language: en-
US,en;q=0.5Accept-Encoding: gzip, deflateUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0)
Gecko/20100101 Firefox/16.0
host: google.com
=========================
HTTP response:
status=404 Not Found
headers= Content-Type: text/html; charset=UTF-8Referrer-Policy: no-referrerContent-Length: 1568Date: Thu, 22 Feb
2018 02:23:09 GMTAlt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337;
quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"
Body=….a bunch of HTML returned with the 404 that I’ve hidden to fit on the slide…
<<<<<<<<<<<<<<<<<<<<<<<<<
8. • Header for requesting compressed content
• http.acceptEncodingHeader("gzip, deflate") or
• .header(HttpHeaderNames.ContentEncoding,"gzip, deflate")
• Compress upload payload
• .processRequestBody(gzipBody)
• .header(HttpHeaderNames.ContentEncoding, "gzip")
GATLING COMPRESSION HEADERS
Don’t forget to act like a browser
8
9. 9
GATLING FEEDERS
Everything is a new thread
• RecordSeqFeederBuilder
• CSV feeders
• JSON feeders
• JDBC feeder
• Sitemap Feeder
• Redis feeder
Documentation
12. CONCURRENTHASHMAP
To share data between threads
12
• Data specific to a user, or situation can be stored in a way
the async threads can access without error.
• Source
13. • API for Pipelining automated testing
• Live charting of performance data (Cassandra)
• Driver machines utilized from cloud providers
• Split load across driver machines
• frontline
GATLING WITH FRONTLINE
Pipeline testing
13
Solving for:
Developers own the perf code, to be updated as part of the same workflow as adding the feature, and QA testing of feature
Existing work flow passes the same work between different owners.
Each one learning the code, and requesting help from previous owners to complete.
Shift left puts more work on the initial developer to own the outcome by owning each of the stages the code passes through.
Reduces Context switching as issues are found and developers need to be spun back up on something old to them.
Programmers are already comfortable with programming solutions. Gatling provides the testing tool in the form of programming a solution.
Example of failure during test run on desktop
Existing work flow passes the same work between different owners. Each one learning the code, and requesting help from previous owners to complete.
Shift left puts more work on the initial developer to own the outcome by owning each of the stages the code passes through.
Reduces Context switching as issues are found and developers need to be spun back up on something old to them.