This document provides an overview of Gatling, an open-source load testing tool developed using Scala. It discusses Gatling's focus on web applications, simplicity, high performance, good reports, and easy integration with CI tools. It then covers setting up Gatling, including prerequisites, writing a sample test, and key concepts like scenarios, simulations, and reports.
2. Overview
What is covered?
Brief about Gatling
Pre-requisites
Writing first test - hands on
What is not covered?
Performance load modelling
Scala language itself
Gradle - Build tool that we have used
3. What is Gatling?
Performance testing framework developed using Scala with a focus on web
applications
Server side
Written in Scala
10. Create a Gradle Project
Edit your build.gradle file:
Add dependencies
Add task gatling
11. Create the Project Skeleton
Create the following structure for your project:
12. Some Keywords
val - constant value
object - class with a single instance
exec - execution step
http - declares an http request
scenario- declares a scenario
Find more : http://gatling.io/#/cheat-sheet/2.2.2
13. Setting up the protocol
This is where we set up:
Base domain for our tests
Example: http://www.example.com/search
Request headers that the target APIs accept
Example: Content-Type: application/json
14. Writing a simple query
A query can be constructed for each endpoint under test. Writing this way would
make the tests simpler and readable
Query consists of:
Query name and request name
Endpoint with request method
Any specific params
Expected response
Syntax:
val <name> = http(<query_name>)
.<request-method>(/endpoint)
.check(<expected_status>)
15. Scenarios
Scenarios are essentially user flows that we would want to simulate.
Usual way to construct a simple scenario is:
Add queries in a sequential manner to create a user journey
Add waits in between if required
Syntax:
val name = scenario(<scenario_name>)
.exec(query1)
.pause()
.exec(query2)
...
16. Simulations
Simulations are where we define the amount of load we want to inject into our
servers
Things required to construct a simulation:
Scenario
Protocol
Assertions
Syntax:
setUp(<scenario>.inject(<injection_step>))
.protocols(<protocol_name>)
.assertions(<condition>)