Library with a bunch of usefull functions that extend Gatling DSL and make your performance better

Gatling Picatinny

Build Maven Central Scala Steward badge

Table of contents

General info

Library with a bunch of useful functions that extend Gatling DSL and make your performance better.


Using Gatling Template Project

If you are using TinkoffCreditSystems/gatling-template.g8, you already have all dependencies in it. Gatling Template Project

Install manually

Add dependency with version that you need

libraryDependencies += "ru.tinkoff" %% "gatling-picatinny" % "0.11.2"



The only class that you need from this module is SimulationConfig. It could be used to attach some default variables such as intensity, baseUrl, baseAuthUrl and some others to your scripts. Also, it provides functions to get custom variables fom config.


import ru.tinkoff.gatling.config.SimulationConfig._

Using default variables:

import ru.tinkoff.gatling.config.SimulationConfig._

val testPlan: Seq[OpenInjectionStep] = List(

Using functions to get custom variable:


stringVariable: "FOO",
intVariable: 1,
doubleVariable: 3.1415,
duration: {
    durationVariable: 3600s
booleanVariable: true
import ru.tinkoff.gatling.config.SimulationConfig._

val stringVariable = getStringParam("stringVariable")
val intVariable = getIntParam("intVariable")
val doubleVariable = getDoubleParam("doubleVariable")
val durationVariable = getDurationParam("duration.durationVariable")
val booleanVariable = getBooleanParam("booleanVariable")


This module contains vast number of random feeders. They could be used as regular feeders and realize common needs, i.e. random phone number or random digit. Now it supports feeders for dates, numbers and digits, strings, uuids, phones. Basic examples will be provided below. Other feeders can be used in a similar way.

import ru.tinkoff.gatling.feeders._

//creates feeder with name 'randomString' that gets random string of length 10
val stringFeeder = RandomStringFeeder("randomString", 10)

//creates feeder with name 'digit' that gets random Int digit
val digitFeeder = RandomDigitFeeder("digit")

//creates feeder with name 'uuid' that gets random uuid
val uuidFeeder = RandomUUIDFeeder("uuid")

HC Vault feeder

Creates feeder capable of retrieving secret data from HC Vault

  • authorises via approle;
  • uses v1 API;
  • works with kv Secret Engine;
  • does not iterate over keys, returns full map with keys it found on each call;
  • params:
    • vaultUrl - vault URL e.g. ""
    • secretPath - path to secret data within your vault e.g. "testing/data"
    • roleId - approle login
    • secretId - approle password
    • keys - list of keys you are willing to retrieve from vault
  val vaultFeeder = VaultFeeder(vaultUrl, secretPath, roleId, secretId, keys)


Creates a feeder with separated values from a source String, Seq[String] or Seq[Map[String, Any]].

  • params:
    • paramName - feeder name
    • source - data source
    • separator - ",", ";", "\t" or other delimiter which separates values. You can also use following methods for the most common separators: .csv(...), .ssv(...), .tsv(...)

Get separated values from a source: String

val sourceString = "v21;v22;v23"
val separatedValuesFeeder: FeederBuilderBase[String] =
  SeparatedValuesFeeder("someValues", sourceString, ';') // Vector(Map(someValues -> v21), Map(someValues -> v22), Map(someValues -> v23))

Get separated values from a source: Seq[String]

val sourceSeq = Seq("1,two", "3,4")
val separatedValuesFeeder: FeederBuilderBase[String] =
  SeparatedValuesFeeder.csv("someValues", sourceSeq) // Vector(Map(someValues -> 1), Map(someValues -> two), Map(someValues -> 3), Map(someValues -> 4))

Get separated values from a source: Seq[Map[String, Any]]

val vaultFeeder: FeederBuilderBase[String] = Vector(
    "HOSTS" -> "host11,host12",
    "USERS" -> "user11",
    "HOSTS" -> "host21,host22",
    "USERS" -> "user21,user22,user23",
val separatedValuesFeeder: FeederBuilderBase[String] =
  SeparatedValuesFeeder(None, vaultFeeder.readRecords, ',') // Vector(Map(HOSTS -> host11), Map(HOSTS -> host12), Map(USERS -> user11), Map(HOSTS -> host21), Map(HOSTS -> host22), Map(USERS -> user21), Map(USERS -> user22), Map(USERS -> user23))

Phone Feeders

Creates a feeder with phone numbers with formats from json file or case class PhoneFormat

Simple phone feeder

val simplePhoneNumber: Feeder[String] = RandomPhoneFeeder("simplePhoneFeeder")

Phone feeder with custom formats

 val ruMobileFormat: PhoneFormat = PhoneFormat(
  countryCode = "+7",
  length = 10,
  areaCodes = Seq("903", "906", "908"),
  prefixes = Seq("55", "81", "111"),
  format = "+X XXX XXX-XX-XX")

  val randomPhoneNumber: Feeder[String]                 =
  RandomPhoneFeeder("randomPhoneNumber", ruMobileFormat)

Phone feeder with custom formats with file

Creates file with formats, for example RESOURCES/phoneTemplates/ru.json

  "formats": [
      "countryCode": "+7",
      "length": 10,
      "areaCodes": ["903", "906"],
      "prefixes": ["123", "321", "132", "231"],
      "format": "+X(XXX)XXXXXXX"
      "countryCode": "8",
      "length": 10,
      "areaCodes": ["495", "499"],
      "prefixes": ["81", "82", "83"],
      "format": "X(XXX)XXX-XX-XX"
val phoneFormatsFromFile: String   = "phoneTemplates/ru.json"
val randomE164PhoneNumberFromJson: Feeder[String]     =
    RandomPhoneFeeder("randomE164PhoneNumberFile", phoneFormatsFromFile, TypePhone.E164PhoneNumber)


This module allows you to write custom points to InfluxDB.

Two kinds of usage

  • Write Start/Stop annotations before/after simulation run
  • Write custom points to InfluxDB
First type denotes start and end of simulation and could be shown in Grafana for example.


import ru.tinkoff.gatling.influxdb.Annotations

For using you should simply add with Annotations for your simulation class:

class LoadTest extends Simulation with Annotations {
  //some code

To see annotations in Grafana you need this two queries, where Perfix is from in gatling.conf:

SELECT "annotation_value"  FROM "${Prefix}" where "annotation" = 'Start'
SELECT "annotation_value"  FROM "${Prefix}" where "annotation" = 'Stop'
Second type allows you to write various data points from your scenario or test plan

!DANGER! Read before use:

  • Not intended for load testing of InfluxDB.
  • You can easily waste InfluxDB with junk data. Don't use frequently changing keys.
  • When recording points in the setUp simulation, a separate script will be created, which will be displayed in the test status in the console and in the final Gatling data.
  • Depending on your settings, Gatling will write simulation data to InfluxDB in batches every n seconds. In this case, the timestamp of the custom point will be taken during its recording, which may cause inaccuracies when displaying data.


import ru.tinkoff.gatling.influxdb.Annotations._


//if default prepared Point doesn't suit you
Point(, System.currentTimeMillis() * 1000000)
  .addTag(tagName, tagValue)
  .addField(fieldName, fieldValue)

//prepare custom Point*

import io.razem.influxdbclient.Point

def customPoint(tag: String, value: String) = Point(, System.currentTimeMillis() * 1000000)
  .addTag("myTag", tag)
  .addField("myField", value) //value: Boolean | String | BigDecimal | Long | Double

*Custom Point reference

//write custom prepared Point from scenario
.userDataPoint(customPoint("custom_tag", "inside_scenario"))

//write default prepared Point from scenario
.userDataPoint("myTag", "tagValue", "myField", "fieldValue")
  //also you can use gatling Expression language for values (could waste DB):
  .userDataPoint("myTag", "${variableFromGatlingSession}", "myField", "${anotherVariableFromSession}")

//write Point from Simulation setUp
    //write point after firstScenario execution
    //"write_first_point" the name of the scenario, will be displayed in the simulation stats
    .userDataPoint("write_first_point", customPoint("custom_tag", "between_scenarios"))
        //similar to simple .userDataPoint, write point after secondScenario execution
          userDataPoint("write_second_point", "custom_tag", "after_second", "custom_field", "end")



  • Load profile configs from HOCON or YAML files
  • Common traits to create profiles for any protocol
  • HTTP profile as an example


import ru.tinkoff.gatling.profile._


HOCON configuration example:

  name: test-profile
  profile: [
      name: request-a
      url: "http://test.url"
      probability: 50.0
      method: get
      name: request-b
      url: "http://test.url"
      probability: 50.0
      method: post
      body: "{\"a\": \"1\"}"

YAML configuration example:

name: test-profile
  - name: request-a
    url: "http://test.url"
    probability: 50
    method: get
  - name: request-b
    url: "http://test.url"
    probability: 50
    method: post
    body: "{\"a\": \"1\"}"

Simulation setUp

  class test extends Simulation {
  val profileConfigName = "profile.conf"
  val someTestPlan = constantUsersPerSec(intensity) during stageDuration
  val httpProtocol = http.baseUrl(baseUrl)
  val config: HttpProfileConfig = new ProfileBuilder[HttpProfileConfig].buildFromYaml(profileConfigName)
  val scn: ScenarioBuilder = config.toRandomScenario



This module allows you to use Redis commands.


  • Support Redis commands: SADD, DEL, SREM
  • Support Gatling EL

Read before use:

  • Мethods are not taken into account in statistics Gatling.
  • Not intended for load testing of Redis.


import com.redis.RedisClientPool
import ru.tinkoff.gatling.redis.RedisActionBuilder._


First you need to prepare RedisClientPool:

val redisPool = new RedisClientPool(redisUrl, 6379)

Add the Redis commands to your scenario chain:

.exec(redisPool.SADD("key", "values", "values")) //add the specified members to the set stored at key
  .exec(redisPool.DEL("key", "keys")) //removes the specified keys
  .exec(redisPool.SREM("key", "values", "values")) //remove the specified members from the set stored at key


This module contains some syntax extensions for http requests with json body. It allows embed json-body in request with jsonBody method for HttpRequestBuilder. And this module is provided ability to send request body templates from files in resource subfolder resources/templates by filename. Sending of templates may be done with method postTemplate from trait Templates


This part contains http request Json body DSL.

For use this you need import this:

import ru.tinkoff.gatling.templates.HttpBodyExt._
import ru.tinkoff.gatling.templates.Syntax._

Then use described later constructions for embed jsonBody in http requests. For example, you write something like this:

class SampleScenario {
  val sendJson: ScenarioBuilder =
    scenario("Post some")
            "id" - 23, // in json - "id" : 23 
            "name", // in json it interpreted as - "name" : get value from session variable ${name}
            "project" - ( // in json - "project" : { ... }
              "id" ~ "projectId", // in json - "id" : value from session var ${projectId}
              "name" - "Super Project", // in json - "name": "Super Project"
              "sub" > (1, 2, 3, 4, 5, 6) // in json - "sub" : [ 1,2,3,4,5,6 ]

As result this scenario sent POST request with body:

  "id": 23,
  "name": "Test",
  "project": {
    "id": 23421,
    "name": "Super Project",
    "sub": [

As you can see in the example:

  • construction "some_name" - <val> map to "some_name": <val> in json;
  • construction "varName" map to "varName" : <get value from session variable ${varName}> in json;
  • construction "some_name" ~ "sesVar" map to "some_name" : <value from session var ${sesVar}> in json;
  • "some_name" > (<...items>) map to array field "some_name": [ ...items ] in json;
  • "some_name" - (<...fields>) map to object field "some_name": { ...fields } in json;


Suppose in folder resources/templates contains this:

$ tree resources/
├── gatling.conf
├── logback.xml
├── pools
│   └── example_pool.csv
├── simulation.conf
└── templates
    └── example_template1.json
    └── example_template2.json

For use templates in resources/templates you need import trait Templates.

import ru.tinkoff.gatling.templates.Templates._

Then add this trait to your Scenario and use postTemplate method like show later:

class SampleScenario extends Templates {
  val sendTemplates: ScenarioBuilder =
    scenario("Templates scenario")
      .exec(postTemplate("example_template1", "/post_route"))
      .exec(postTemplate("example_template2", "/post_route"))

This Scenario will send 2 post requests one with body from example_template1.json, second with body from example_template2.json to route $baseUrl/post_route. In template files you may use gatling expression syntax.




  • Generates a JWT token using a json template and stores it in a Gatling session, then you can use it to sign requests.


import ru.tinkoff.gatling.utils.jwt._


First you need to prepare jwt generator. For example

val jwtGenerator = jwt("HS256", jwtSecretToken)

This will generate tokens with headers:

  "alg": "HS256",
  "typ": "JWT"

Payload will be generated from json template, templating is done using Gatling EL

  "userName": "${randomString}",
  "date": "${simpleDate}",
  "phone": "${randomPhone}"

Also, the JWT generator has a DSL allowing you to:

jwt("HS256", secret)
  .header("""{"alg": "HS256","typ": "JWT", "customField": "customData"}""") //use custom headers from string, it must be valid json
  .headerFromResource("jwtTemplates/header.json") //use src/test/resources/jwtTemplates/header.json as header template
  .defaultHeader //use default jwt header, algorithm from jwt("HS256", secret), template: {"alg": "$algorithm","typ": "JWT"}
  .payload("""{"userName": "${randomString}","date": "${simpleDate}","phone": "${randomPhone}"}""") //use custom payload from string, it must be valid json
  .payloadFromResource("jwtTemplates/payload.json") //use src/test/resources/jwtTemplates/payload.json as payload template

For sign requests add this to your scenario chain:

    .exec(_.setJwt(jwtGenerator, "jwtToken")) //generates token and save it to gatling session as "jwtToken"
  .exec(addCookie(Cookie("JWT_TOKEN", "${jwtToken}").withDomain(jwtCookieDomain).withPath("/"))) //set JWT_TOKEN cookie for subsequent requests


Module helps to load assertion configs from YAML files


import ru.tinkoff.gatling.assertions.AssertionsBuilder.assertionFromYaml


File nfr contains non-functional requirements.

Requirements supported by Picatinny:

requirement key
99th percentile of the responseTime 99 перцентиль времени выполнения
95th percentile of the responseTime 95 перцентиль времени выполнения
75th percentile of the responseTime 75 перцентиль времени выполнения
50th percentile of the responseTime 50 перцентиль времени выполнения
percent of the failedRequests Процент ошибок
maximum of the responseTime Максимальное время выполнения

YAML configuration example:

  - key: '99 перцентиль времени выполнения'
      GET /: '500'
      MyGroup / MyRequest: '900'
      request_1: '700'
      all: '1000'
  - key: 'Процент ошибок'
      all: '5'
  - key: 'Максимальное время выполнения'
      GET /: '1000'
      all: '2000'

Simulation setUp

  class test extends Simulation {



This extension introduce new syntax (startTransaction/endTransaction) for gatling scenario. Transaction is union of actions, that able to measure summary response time of actions with pauses. It is same as groups, but response time measuring include pauses, and you may pass endTime manually. That make possible write something like:

  .doWhile(_ ("i").as[Int] < 10)(


For use this you need gatling with version greater or equal than 3.6.1 and import this in Scenario and Simulations:

import ru.tinkoff.gatling.transactions.Predef._

Attention! Your simulation should inherit the class SimulationWithTransactions instead of Simulation, then the transaction mechanism will work correctly.

Example Simulation:

import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder

import ru.tinkoff.gatling.transactions.Predef._

object DebugScenario {
  val scn: ScenarioBuilder = scenario("Debug")
    .doWhile(_ ("i").as[Int] < 10)(

class DebugTest extends SimulationWithTransactions {




See the examples in the examples/ directory.

You can run these from the sbt console with the commands project example and then gatling:testOnly ru.tinkoff.load.example.SampleSimulation.

Ensure that the correct InfluxDB parameters are specified in gatling.conf and influx.conf.


To test your changes use sbt test.

Built with

  • Scala version: 2.13.8
  • SBT version: 1.6.1
  • Gatling version: 3.7.4
  • SBT Gatling plugin version: 4.1.2
  • SBT CI release plugin version: 1.5.10
  • json4s version: 4.0.2
  • pureconfig version: 0.17.1
  • scalatest version: 3.2.10
  • scalacheck version: 1.15.4
  • scalamock version: 5.2.0
  • generex version: 1.0.2
  • jwt-core version: 5.0.0
  • scala influxdb client 0.6.3


telegram: @qa_load

gatling docs:


We use SemVer for versioning. For the versions available, see the tags on this repository.


See also the list of contributors who participated in this project.


This project is licensed under the Apache 2.0 License - see the LICENSE file for details