17. May 2019
timer-icon 1 min

Gatling DataWriters as JVM Property

One of my customers uses Gatling to continuously run load tests for a web portal. I faced the challenge that test results should dynamically be written to various backends. Since changing the gatling.conf before each test was not an option I was wondering how to pass a list of datawriters to Gatling as JVM argument.

Gatling is an open-source load and performance testing tool written in Scala. By default Gatling supports the following storage backends: console, file, graphite, jdbc. To configure the utilized backend you need to modfiy the gatling.conf.


The Gatling documentation [1] offers two possibilities to override configuration values:

  1. Change the value in gatling.conf.
  2. Set a System property (the name of the property must match HOCON Path [2])

Since option 1. is not an option – let’s go with system properties. But wait, what the hell is HOCON Path and how do I define a list property in HOCON Path?

HOCON stands for “Human-Optimized Config Object Notation” and its primary goal is: keep the semantics (tree structure; set of types; encoding/escaping) from JSON, but make it more convenient as a human-editable config file format.

Solution

As shown in gatling.conf the datawriter property resolves to: gatling.data.writers.

If you read through the HOCON docs carefully you can see the following statement:

This allows creating an array in a properties file like this:

Long story short, to invoke Gatling and pass a list of datawriters looks as follows:

Sources

[1] https://gatling.io/docs/2.3/
[2] https://github.com/lightbend/config/blob/master/HOCON.md#hocon-human-optimized-config-object-notation
[3] https://github.com/gatling/gatling/issues/3055

Image Sources:

Comment article