tesladev
tesladev

Reputation: 43

Gatling's andThen() is not getting executed

As part of a single Simulation, I want to run:

The setup is presented below:

import io.gatling.javaapi.core.CoreDsl.*
import io.gatling.javaapi.core.OpenInjectionStep.atOnceUsers
import io.gatling.javaapi.core.Simulation
import io.gatling.javaapi.http.HttpDsl.http
import java.time.Duration

class ComputerDatabaseSimulation : Simulation() {

    private val warmUp = scenario("WarmUp")
        .forever()
        .on(exec(http("[WarmUp] GET /computer-database.gatling.io").get("https://computer-database.gatling.io/computers")))

    private val testScn = scenario("TestScn")
        .forever()
        .on(exec(http("[TestScn] GET /computer-database.gatling.io").get("https://computer-database.gatling.io/computers")))

    init {
        setUp(
            warmUp
                .injectOpen(atOnceUsers(5))
                .throttle(
                    reachRps(2).during(Duration.ofSeconds(5)),
                    holdFor(Duration.ofSeconds(10))
                )
                .andThen(
                    testScn
                        .injectOpen(atOnceUsers(5))
                        .throttle(
                            jumpToRps(2),
                            holdFor(Duration.ofSeconds(10))
                        )
                )
        )
    }

}

Unfortunately, only “WarmUp” scenario is executed, the “TestScn” is totally skipped:

gradle gatlingRun --simulation=ComputerDatabaseSimulation

> Task :load-tests:gatlingRun
Simulation ComputerDatabaseSimulation started...

================================================================================
2024-11-17 15:33:13 GMT                                       5s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=4      KO=0     )
> [WarmUp] GET /computer-database.gatling.io               (OK=4      KO=0     )

---- WarmUp --------------------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 5      / done: 0     
---- TestScn -------------------------------------------------------------------
[                                                                          ]  0%
          waiting: 5      / active: 0      / done: 0     
================================================================================


================================================================================
2024-11-17 15:33:18 GMT                                      10s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=14     KO=0     )
> [WarmUp] GET /computer-database.gatling.io               (OK=14     KO=0     )

---- WarmUp --------------------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 5      / done: 0     
---- TestScn -------------------------------------------------------------------
[                                                                          ]  0%
          waiting: 5      / active: 0      / done: 0     
================================================================================


================================================================================
2024-11-17 15:33:18 GMT                                      10s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=14     KO=0     )
> [WarmUp] GET /computer-database.gatling.io               (OK=14     KO=0     )

---- WarmUp --------------------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 5      / done: 0     
---- TestScn -------------------------------------------------------------------
[                                                                          ]  0%
          waiting: 5      / active: 0      / done: 0     
================================================================================

Parsing log file(s)...
Parsing log file(s) done in 0s.
Generating reports...

================================================================================
---- Global Information --------------------------------------------------------
> request count                                         14 (OK=14     KO=0     )
> min response time                                    118 (OK=118    KO=-     )
> max response time                                    428 (OK=428    KO=-     )
> mean response time                                   215 (OK=215    KO=-     )
> std deviation                                        121 (OK=121    KO=-     )
> response time 50th percentile                        130 (OK=130    KO=-     )
> response time 75th percentile                        360 (OK=360    KO=-     )
> response time 95th percentile                        428 (OK=428    KO=-     )
> response time 99th percentile                        428 (OK=428    KO=-     )
> mean requests/sec                                    1.4 (OK=1.4    KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                            14 (   100%)
> 800 ms <= t < 1200 ms                                  0 (     0%)
> t >= 1200 ms                                           0 (     0%)
> failed                                                 0 (     0%)
================================================================================

BUILD SUCCESSFUL in 15s
4 actionable tasks: 4 executed

What am I doing wrong? I'm using the latest Gatling version 3.13.1

Cheers!

Upvotes: 0

Views: 35

Answers (1)

St&#233;phane LANDELLE
St&#233;phane LANDELLE

Reputation: 6623

Duplicating here the answer on the Gatling community forum:

The issue is with your forever loop in your warmUp scenario. As expected, it make the virtual users of this scenario to loop forever, so they never complete and Gatling doesn’t proceed with the next scenario.

Maybe you’re expecting your throttle to stop all the virtual users of this scenario to stop after 15 seconds but that’s not how throttle works: the limit is lifted after 15s.

Upvotes: 0

Related Questions