You are on page 1of 8

Gatling

Introduction

Section C - Accompanying Documentation


Table of contents

Section C Overview 3

Gatling Workload Models 4


Closed Workload 4
Open Workload 4

Adding Simulation Design to Script 5

Executing Gatling Scripts 6


Standalone Mode 6
Maven 6
Gradle 6
SBT 7
Gatling Test Reports 8

Gatling Academy - Gatling Introduction - Section A


Page 2
Section C Overview
Section C of this course is titled ​Gatling Test Simulation Design, Execution and
Reporting.​ The following topics will be covered:

● Open and Closed Workload Models


● Adding a Simulation to a Gatling script
● Executing Gatling via the Standalone Version
● Executing Gatling via Build Tools
● Gatling Test Reports

Gatling Academy - Gatling Introduction - Section A


Page 3
Gatling Workload Models
Gatling supports both the Open and Closed workload models. You can read more about the
differences between the workload models in this blog post -
https://gatling.io/2018/10/04/gatling-3-closed-workload-model-support/

The documentation on simulation design also has details of the differences between the
models and describes the DSL methods that Gatling provides for simulation design:
https://gatling.io/docs/current/general/simulation_setup/#open-vs-closed-workload-models

Closed Workload

The methods for a closed workload model are described here:


https://gatling.io/docs/current/general/simulation_setup/#closed-model

Open Workload

The methods for an open workload model are described here:


https://gatling.io/docs/current/general/simulation_setup/#open-model

Gatling Academy - Gatling Introduction - Section A


Page 4
Adding Simulation Design to Script
Gatling simulation design is defined in the ​setUp() ​block of your Gatling script, typically
located at the bottom. Here you can pick methods from the Gatling DSL to design load
simulations as you see fit.

This is an example of a simulation with 5 admin users that start at once, along with a number
of regular users that ramp at different intervals:

setUp​(​admins​.​inject​(​atOnceUsers​(​5​))​,
​users​.​inject​(
​nothingFor​(​5​)​,
​atOnceUsers​(​1​)​,
​rampUsers​(​5​) ​during ​(​10​)​,
​constantUsersPerSec​(​20​) ​during ​(​20​)
))
.​protocols​(​httpProtocol​)

We can expect the scenario above to look something like this:

Good practice in designing your load simulation is to check this ​Active Users along the
Simulation ​graph in your Gatling test reports, and then adjust your load injection simulation
as required.

Remember to check the documentation and Gatling cheat sheet (


https://gatling.io/docs/current/cheat-sheet/​ ) for all the different injection profiles that you can
add into your Gatling script.

Gatling Academy - Gatling Introduction - Section A


Page 5
Executing Gatling Scripts

Standalone Mode

Executing Gatling in standalone mode means simply executing the ​gatling.sh ​or ​gatling.bat
file within the ​/bin​ folder of the Gatling download that you extracted on your machine.

Remember that your Gatling simulation scripts should be within the​ user-files/simulations
folder of that same repository, and any support files such as CSV data files should be in the
user-files/resources/data ​folder.

Maven

To execute a Gatling script through Maven, use the following command:

$ mvn gatling:​test​ -Dgatling.simulationClass=computerdatabase.BasicSimulation

Refer to the Maven Plugin documentation for full instructions on using Gatling with Maven -
https://gatling.io/docs/current/extensions/maven_plugin/

Gradle

To execute a Gatling script through Gradle, use the following command:

$ gradle gatlingRun-com.project.simu.MySimulation

Refer to the Gradle plugin documentation for full instructions on using Gatling with Gradle -
https://github.com/gatling/gatling-gradle-plugin

Gatling Academy - Gatling Introduction - Section A


Page 6
SBT

To execute a Gatling script through SBT, first run ​sbt​ from the console, then type:

> gatling:testOnly computerdatabase.BasicSimulation

Refer to the SBT Gatling Plugin documentation for further information -


https://gatling.io/docs/current/extensions/sbt_plugin/

Gatling Academy - Gatling Introduction - Section A


Page 7
Gatling Test Reports

Gatling produces a detailed graphical test report at the end of each test execution. The
report will look something like this:

Please refer to the documentation for a full breakdown of Gatling reports -


https://gatling.io/docs/current/general/reports/

Gatling Academy - Gatling Introduction - Section A


Page 8

You might also like