Gatling tests

This topic describes how to use Gatling load testing scripts in Controller scenarios.

Note: Use of Gatling scripts is provided as a tech preview feature. Currently you do not need a license to run Gatling scripts in Controller. However, this may change in future versions.

Gatling tests overview

Gatling is an open source load and performance testing tool (gatling.io/open-source). Gatling is used for analyzing and measuring the performance of web servers and web applications. Gatling uses Scala programming language to create test scripts.

LoadRunner Professional supports integration of Gatling (.scala) test scripts in your scenarios. You can run one or more Gatling scripts alongside any other LoadRunner Professional protocol script in a scenario.

Gatling scripts have two significant features:

  • Every Gatling script file contains all the necessary run settings within the script code.
  • Gatling scripts contain a series of HTTP requests and pauses. Each request is reported as a transaction.

Measurements can be viewed online and offline (via Controller and Analysis), using the data points from the Gatling tests.

Back to top

Prerequisite setup for Gatling tests

Gatling scripts can be run on a load generator on a Windows or Linux operating system.

Tip: We recommend that you use dedicated load generator machines for running Gatling test scripts. Running tests from Controller, using the localhost load generator, may cause some instability.

To prepare your environment for running Gatling scripts:

  1. Install the following on each load generator and machine that will run a Gatling test:

    • Gatling open source version 3.x.
    • Java Development Kit (JDK). Make sure it is the appropriate version for the installed Gatling version.

  2. For each LoadRunner agent installation, define an environment variable called GATLING_HOME, and restart the LoadRunner agent.
  3. We recommend setting the logback level in <Gatling root folder>\config\logback.xml to INFO so that LoadRunner Professional can obtain more detailed log data from the script at runtime.

Data files

The Gatling script may reference parameter files in other formats (.csv, .ssv, .tsv, .json, xml).

If the Gatling script uses other files, make sure:

  • All other files are in the same folder (and not a subfolder) as the .scala script file.
  • The reference path in the Gatling script correctly points to the other files.

Controller will find these files, and send them with the .scala file to the load generator for execution.

Back to top

Using a Gatling script in a scenario

A Gatling script is triggered as a separate process on the computer, and is not controlled by LoadRunner Professional.

Note: Network Virtualization is not supported for Gatling tests.

To define a Gatling scenario:

  1. Make sure the load generator machines are set up to run Gatling tests, as described in Prerequisite setup for Gatling tests.
  2. On the main Controller toolbar, click the New Scenario button .
  3. In the New Scenario dialog box, in the Select the scripts... area, select the Gatling Scripts radio button.
  4. Click Browse and select the Gatling script (.scala file).
  5. Click OK in the New Scenario dialog box. The scenario containing the Gatling script opens in the Design tab.
  6. Right-click the script name, and select Runtime Settings.

    In Runtime Settings, enter the root path of the Gatling software installation on the load generator.

    If the Gatling path field is left empty, Controller uses the path defined for the GATLING_HOME environment variable (see Prerequisite setup for Gatling tests).

  7. Scenario settings are defined within the Gatling script. The following settings can be defined in Global Schedule:

    • Duration: Set to Run until completion. Recommended setting.
    • Start Vusers. Enter 1 Vuser for each load generator.

      If running the same script on multiple load generators, use this field to specify the number of load generators; this causes the Gatling script to run on each load generator.

  8. In the Run tab, click the Start Scenario button to begin running the scenario.

Back to top

Sample Gatling script

In the sample file you can see:

  • The test ramps up to 5 users within 30 seconds.
  • The script will run for 2 minutes.
  • Each iteration contains 2 requests = 2 transactions
package com.mf.lr

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class LRDemoSimulation extends Simulation {

  val httpProtocol = http
    .baseUrl("http://www.bing.com") // Here is the root for all relative URLs
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
    .doNotTrackHeader("1")
    .acceptLanguageHeader("en-US,en;q=0.5")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

  val scn = scenario("Scenario Name") // A scenario is a chain of requests and pauses
    .exec(http("request_1")
      .get("/"))
    .pause(1)
    .exec(http("request_2")
      .get("/search?q=Gatling"))
    .pause(2)    
  
  setUp(scn.inject(rampUsers(5) during (30 seconds)).protocols(httpProtocol)).maxDuration(2 minutes)
}

Back to top

View Gatling test results

Every HTTP request in the Gatling script is reported as a transaction.

Gatling scripts produce results that are displayed in the following standard Controller graphs:

  • Running Vusers
  • Transaction Response Time
  • Hits per Second
  • Total Trans/Sec (Passed)
  • Trans/Sec (Passed)
  • HTTP Response per Second

The standard Throughput graph does not display results from Gatling scripts. Customized graphs cannot be generated from Gatling script results.

Back to top

See also: