shadrik
shadrik

Reputation: 359

Gatling 2.0 throttle does not send any requests

I am trying to run simple Gatling scenario with throttle functionality but no requests are sent to the server.

I am using Gatling 2.0.2, Java 1.8.0_25, Maven 3.2.3 (all running on OS X)

My code looks like this:

object RequestHomePage {

  def apply() = {
      exec(http("Home Page Request")
        .get("http://my.page/home")
        .header("Accept", "application/xml,application/xhtml+xml")
  }
}

object HomePage {

  val executeScenario = scenario("Home Page Retrieval")
                                  exec(RequestHomePage())
}

class PerformaceSimulation extends Simulation {

  val maxResponseTime = 5000 // milliseconds

  val simultaneousUsers = atOnceUsers(100)

  setUp(HomePage.executeScenario
          .inject(atOnceUsers(100))
          .throttle(jumpToRps(1), holdFor(10 seconds))
    )
    .protocols(httpProtocol)
    .assertions(
      global.responseTime.max.lessThan(maxResponseTime)1
    )
}

The output is the following:

    ================================================================================
    2015-02-20 16:39:41                                           4s elapsed
    ---- Home Page Retrieval -------------------------------------------------------
    [##########################################################################]100%
              waiting: 0      / active: 0      / done:100   
    ---- Requests ------------------------------------------------------------------
    > Global                                                   (OK=0      KO=0     )

    ================================================================================
Simulation finished
Parsing log file(s)...
Parsing log file(s) done
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at scala_maven_executions.MainHelper.runMain(MainHelper.java:164)
    at scala_maven_executions.MainWithArgsInFile.main(MainWithArgsInFile.java:26)
Caused by: java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won't be generated

Does anyone have any idea why would throttle(...) not send any request? Thanks

Upvotes: 4

Views: 3135

Answers (2)

shadrik
shadrik

Reputation: 359

After a discussion with @stephane-landelle in Gatling's user group (https://groups.google.com/forum/#!topic/gatling/QW212U3hDus) the solution was to use:

.inject(constantUsersPerSec(numberOfUsers) during(loadDuration seconds)) 

in

setUp(scenario
  .inject(constantUsersPerSec(numberOfUsers) during(loadDuration seconds))
)
.protocols(httpProtocolConfig)
.assertions(
  global.responseTime.max.lessThan(maxResponseTime)
)

IMPORTANT: The first note in Gatling 2.1.4 documentation about Throttling (http://gatling.io/docs/2.1.4/general/simulation_setup.html#throttling) is crucial for one's understanding on constant number of rps and the function of throttle(...) acting as a upper bound of requests per second.

Upvotes: 1

Stephane Landelle
Stephane Landelle

Reputation: 7038

There's been several bug fixes regarding throttling since 2.0.2. Please upgrade to 2.1.4.

Upvotes: 1

Related Questions