Gatling Executor

Gatling is load testing tool which most famous as choice for testing of HTTP servers.

In Taurus you have two way for run it: with native gatling script or with usual Taurus features: requests, iterations, etc. In last case scala script will be generated automatically.

We support Gatling version 3+.

Run Gatling Tool

- executor: gatling
  scenario: sample

    script: tests/gatling/BasicSimulation.scala
    simulation: tests.gatling.BasicSimulation

The simulation option is canonical class name for main simulation class. It will be passed as-is to gatling with -s option.

Load Configuration

Taurus supports possibility to send values of execution options concurrency, iterations, ramp-up hold-for and throughput to Gatling test script. Below you can see how you can use these parameters on the Gatling side to set up your test:

package tests.gatling
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class BasicSimulation extends Simulation {
  // parse load profile from Taurus
  val t_iterations = Integer.getInteger("iterations", 100).toInt
  val t_concurrency = Integer.getInteger("concurrency", 10).toInt
  val t_rampUp = Integer.getInteger("ramp-up", 1).toInt
  val t_holdFor = Integer.getInteger("hold-for", 60).toInt
  val t_throughput = Integer.getInteger("throughput", 100).toInt
  val httpConf = http.baseUrl("")
  // 'forever' means each thread will execute scenario until
  // duration limit is reached
  val loopScenario = scenario("Loop Scenario").forever() {
  // if you want to set an iteration limit (instead of using duration limit),
  // you can use the following scenario
  val iterationScenario = scenario("Iteration Scenario").repeat(t_iterations) {
  val execution = loopScenario
    .inject(rampUsers(t_concurrency) during t_rampUp)
    throttle(jumpToRps(t_throughput), holdFor(t_holdFor)).
    maxDuration(t_rampUp + t_holdFor)

Running Complex Gatling Test Suites

If your Gatling test suite is really huge or has dependencies on other files - you can bundle it in a jar (with the help of sbt or Maven) and then run this jar with Taurus. Just specify it as a script value in scenario.

- executor: gatling
  scenario: sample

    script: simulations.jar
    simulation: tests.gatling.BasicSimulation

Building Test Script from Config

If your scenario don't contains script parameter and contains at least one element of requests Taurus will build scala script for test. This script will be placed in artifact-dir: you can modify it and use with Gatling later.

Following features are supported:

  • request generation
  • on scenario level: think-time, default-address, follow-redirects, headers, store-cache, keepalive,

timeout, retrieve-resources, retrieve-resources-regex

Some asserts can be added to request. Assert describes templates and area for search (contains and subject accordingly), regexp and inverse marks. You can look for particular response code in http-code part or for string and regular expression in body of request. Next yaml example shows the way these features can be used and ready to conversion to scala automatically:

- executor: gatling
  iterations: 15
  concurrency: 3
  ramp-up: 2
  hold-for: 10
  scenario: complex_sample

    data-sources:  # this is a list of data-sources options for Gatling. See more info below.
    - path: buyouts.csv 
      delimiter: ','
      loop: true
    store-cache: true  # cache HTTP responses, true by default
    retrieve-resources: true # false by default, retrieves all embedded resources from HTML pages
    retrieve-resources-regex: (.*)boo(.*) # regular expression used to match any resource (white list)
      HEADER_1: VALUE_1
      HEADER_2: VALUE_2
    - url: /
      - subject: body # subject for search (defalut: body)
        regexp: true  # whether expression is regular (default: false)
        not: true     # invert condition (default: false)
        contains: # expression list for assertion (mandatory)
        - .+sometext.+  
      body: 'Some Body Data'    # can be string or dictionary
      follow-redirects: false    #   true by default
        HEADER_11: VALUE_11
    - url: /reserve.php
      think-time: 2s
      - contains:
        - 200
        subject: http-code
        not: true
    - /purchase.php?username=${username}&email=${email}  # usage of variables from the CSV data source
    - set-variables:  # setting variables in runtime
        var1: val1
        var2: val2

See more info about data-sources here.

Configuration Options

Similar to other modules there is possibility of global configuration Gatling Executor by write some lines in gatling section of modules setting. Next options can be set:

  • path: Path to Gatling executable. In case no Gatling executable found, it will be automatically downloaded and installed into path location. By default ~/.bzt/gatling-taurus/{version}/bin/
  • java-opts: string with some java options for Gatling
  • download-link: Link to download Gatling from. By default:{version}/gatling-charts-highcharts-bundle-{version}
  • version: Gatling version, 3.1.2 by default
  • dir-prefix: Gatling report prefix, gatling-%s by default. Used by taurus to find gatling reports. If you use Gatling property gatling.core.outputDirectoryBaseName, you may use also this setting.
  • properties: dictionary for tuning of gatling tool behaviour (see list of available parameters in gatling

documentation) and sending your own variables into Scala program:

    properties: 512 # output buffer size, 256 bytes by default
      your_variable: 1024               # user variable

You can then read values of properties in Scala code similar to Load Configuration style:

class BasicSimulation extends Simulation {
  val your_scala_variable = Integer.getInteger("your_variable", 0).toInt

You can also specify properties per-scenario, which will add to module-level properties:

      propname: value
      your_variable: 256
    # ...

External Java Libraries Usage

Thanks to Taurus you can use additional Java classes in your scala code. For that purpose add required jar files or contained dir to additional-classpath list:

- executor: gatling
  concurrency: 10
  hold-for: 1h
  scenario: example
    script: my_file.scala
    - deps/gson-1.0.1.jar
    - deps/common-utils-0.15.1.jar
    - most-important-lib.jar  #   global way to specify required libraries