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)

  setUp(scn.inject(constantUsersPerSec(Integer.getInteger("users", 1).toDouble) during (5 minutes)).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 Add Files (or Create File) button to upload the DemoSimulation.scala file as specified above. For more complex tests you can upload feeders, bodies, CSV files, etc or 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. Gatling Instances: Number of Gatling instances that will execute your Gatling simulation. Control test duration/iterations from within your Gatling simulation code.
  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.