mateusz gruszczynski - performance tests in gatling (quality questions conference)
TRANSCRIPT
![Page 2: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/2.jpg)
Performance Testing
● Why we should test performance?● What are performance tests?
– Performance
– Load
– Stress
– Soak
– Capacity
![Page 3: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/3.jpg)
How to test performance
● Functional vs Non-Functional approach
● Setting goals● Good practices● Understanding architecture and
tech stack● Analyzing results
![Page 4: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/4.jpg)
Why Gatling?
● Asynchronous● Actor model● Non blocking I/O● Simple configuration● GUI and DSL● Easy to understand code● Extendable
![Page 5: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/5.jpg)
http://gruszczynski.pl/WSTest.zip
![Page 6: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/6.jpg)
HTTP & REST
● Request methods– GET, POST, PUT, PATCH, DELETE ...
● Headers● HTTP Codes
– 200, 201, 400, 401, 402, 422, 500
● Session● Authentication● REST
![Page 7: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/7.jpg)
Gatling GUI
● Works as proxy server● Allows to record requests● Generates simulation code● No coding required● Allows to replay recorded
simulations● Generates reports
![Page 8: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/8.jpg)
http://gatling.io/
![Page 9: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/9.jpg)
Simulation Report
● Summary and per request reports● Multiple metrics● Time distribution● Detailed statistics
![Page 10: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/10.jpg)
Lets look at some code
● Simulations are written in Scala● Simulations use Gatling DSL to configure requests● Simulation is a set of scenarios● Generated requests are very simple● Generated code is messy● Complex logic can (should) be added to scenario
![Page 11: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/11.jpg)
Basic Gatling DSL elements
● Requests● Checkers● Assertions● Loops● Condition Blocks● more: Cheat sheet
![Page 12: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/12.jpg)
http://gruszczynski.pl/api.php/
![Page 13: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/13.jpg)
Writing first request
● Setting simple GET request● Validating response code● Validation response content
– HTML response
– JSON response
● Configuring assertions and success conditions
![Page 14: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/14.jpg)
We need more users!
● Injecting users● Injection strategies
– atOnceUsers
– rampUsers
– constantUsersPerSec
– rampUsersPerSec
– mixed strategies
● Injection strategies vs request per second
● Throttling
![Page 15: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/15.jpg)
Gatling Session
● Storing data in session● Reusing stored data in
scenarios● Filling placeholders● Coding inside session
context (block)
![Page 16: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/16.jpg)
Configuring request parameters
● URL– base URL
– URL params
● Headers– content type
– authorization
● Resources
![Page 17: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/17.jpg)
Passing request data
● StringBody● RawFileBody● Constructing data based on
session
![Page 18: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/18.jpg)
Checking response
● Status● Content
– HTML
– JSONPath
● Headers● Response Time
![Page 19: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/19.jpg)
Writing global assertions
● Max time● Average time● Percentiles● Detail
![Page 20: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/20.jpg)
Loops and conditions
● Conditions
– doIf ...
– doSwitch
– randomSwitch
– etc.
● Failure conditions
– tryMax
– exitBlockOnFail
– exitHereIfFailed
● Loops
– forever
– repaet
– during
– foreach
– asLongAs
![Page 21: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/21.jpg)
Loading data to simulation
● Feeder sources– Files
● CSV ...● Json
– Remote files
– Databases● JDBC● Redis
● Feeder strategies– queue
– shuffle
– random
– circular
![Page 22: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/22.jpg)
Advanced reporting & monitoring
● LogBack● JSON Stats● ExtraInfoExtractor● Live monitoring
– Graphite
– InfluxDB
![Page 23: Mateusz Gruszczynski - Performance tests in Gatling (Quality Questions Conference)](https://reader033.vdocument.in/reader033/viewer/2022042908/58f10de81a28ab8d258b457f/html5/thumbnails/23.jpg)
Questions?