Correct usage of exitHereIfFailed with several scenarios in the same simulation?

839 views
Skip to first unread message

mstaalesen

unread,
Nov 30, 2015, 9:41:01 AM11/30/15
to Gatling User Group
I have a question regarding exitHereIfFailed and how to properly use it to stop a simulation with several scenarios.

I am executing gatling via Maven, and I would like to get a BUILD FAILURE response from Gatling/Maven if any requests fail.I would also like the
simulation to stop at once when something is wrong with any of the scenarios. I've attempted to achieve this, but I have not 100 successful so far.

Simplified example of how the code looks right now (not my actual code, but I added it to try to explain what I'm doing right now):

class ExampleSimulation extends Simulation {

val httpProtocol
= http
     
.baseURL("http://localhost:8080")

object Scenario1 {
   val sc1 = during(60 seconds) {
     exitBlockOnFail(
       exec(http("Scenario1 - First request")
         .post("/path")
         (.....)
         .check(status.is(201)))
         .exec(http("Scenario1 - Second request")
         .post("/path/2")
         (.....)
         .check(status.is(201)))
         ) .exitHereIfFailed
   }
 }

  object Scenario2 {
     val sc2 = during(180 seconds) {
       exitBlockOnFail(
         exec(http("Scenario2 - First request")
           .post("/path")
           (.....)
           .check(status.is(201)))
           .exec(http("Scenario2 - Second request")
           .post("/path/2")
           (.....)
           .check(status.is(201)))
            .exec(http("Scenario2 - Third request")
           .post("/path/3")
           (.....)
           .check(status.is(201)))
           ) .exitHereIfFailed
     }
   }

  val scen1 = scenario("Scenario 1").exec(Scenario1.sc1)
 val scen2 = scenario("Scenario 2").exec(Scenario2.sc2)
 setUp(scen1.inject(atOnceUsers(10)),
       scen2.inject(atOnceUsers(2))
     ).protocols(httpProtocol)
       .assertions(
       global.successfulRequests.percent.is(100)
     )
}

The result of this code is that the scenarios are stopped when there is a problem with a request in said scenario, not the whole simulation. (Which I assume is the way it is supposed to work).
I get the BUILD FAILURE via .assertions(), but I have to wait 60/180 seconds (Scenario 1/Scenario 2 durations) if only one of the scenarios fails. I would like the user to be informed about the failure
as soon as possible (e.g if this was to be used for a test that runs for 24 hours)

Is is possible to use .exitHereIfFailed to stop the whole simulation at once when one requests is KO? Or are there perhaps any other ways to solve this?

mstaalesen

unread,
Nov 30, 2015, 9:49:11 AM11/30/15
to Gatling User Group
From Stéphane Landelle in my previous thread that I deleted:
exitHereIfFailed forces the current virtual user to exit, not the scenario nor the whole simulation.
Reply all
Reply to author
Forward
0 new messages