Getting Started - Gatling

Follow this guide for a basic example of running a Gatling simulation. For our example we will use a really simple simulation which simply makes an HTTP GET request for http://sample.testable.io/stocks/IBM.

DemoSimulation.scala

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

class DemoSimulation extends Simulation {

  val httpConf = http
    .baseUrl("http://sample.testable.io") // Here is the root for all relative URLs
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

  val scn = scenario("Testable Demo") // A scenario is a chain of requests and pauses
    .exec(http("request_1")
      .get("/stocks/IBM"))
      .pause(5)

  val duration = Duration.apply(Integer.getInteger("duration", 60).toLong, "seconds")
  setUp(scn.inject(constantUsersPerSec(Integer.getInteger("users", 1).toDouble) during (duration)).protocols(httpConf))
}

Start by signing up and creating a new test case using the Create Test button on the dashboard.

Enter the test case name and then press Next.

Scenario

Select Gatling Simulation as the Scenario type.

Click the Create File icon to create a DemoSimulation.scala file and use the above code as the content. For more complex tests you can upload feeders, bodies, CSV files, etc; upload a zip file that will get unzipped on the test runner; or link this scenario to a version control repository.

Scenario

Click the Smoke Test button in the upper right to run your test plan with 1 user and 1 iteration on a Testable test runner. The output of the run will show up in the Smoke Test Output once it finishes.

And that’s it, we’ve now defined our scenario! Click on the Configuration tab or press the Next button at the bottom to move to the next step.

Configuration

Now that we have the scenario for our test case we need to define a few parameters before we can execute our test:

  1. Total Load: Choose Basic to specify the total virtual users, # of Gatling engines, and duration via the Testable UI. The engines will get a users and duration system property when the test runs so your code will need to make sure to read those values. Alternatively, choose Advanced and simply specify how many Gatling engines to spin up with the load parameters either hard-coded or past via scenario params.
  2. Location(s): Choose the location in which to run your test and the test runner source that indicates which test runners to use in that location to run the load test (e.g. on the public shared grid).

And that’s it! Press Start Test and watch the results start to flow in. See the new configuration guide for full details of all configuration options.

For the sake of this example, let’s use the following parameters:

Test configuration

View Results

Once the test starts executing, Testable will distribute the work out to the selected test runners (e.g. Public Shared Grid in AWS N. Virginia).

Test results

You can see various graphs, metrics, and grids in the results. If you click on any resource in the results grid, the charts below will update to be specific to that resource only.

Check out the Gatling guide for more details on running your Gatling tests on the Testable platform.

We also offer integration (Org Management -> Integration) with third party tools like New Relic. If you enable integration you can do more in depth analytics on your results there as well.

That’s it! Go ahead and try these same steps with your favorite website or API and feel free to contact us with any questions.