加特林的 andThen() 没有被执行

问题描述 投票:0回答:1

作为单个模拟的一部分,我想运行:

  • 预热场景,从 0 RPS 开始,逐渐增加到 $target RPS,并保持#target RPS 几秒钟
  • 预热完成后,我想运行真实的负载测试,立即跳至 $target RPS,并保持流量一段时间

设置如下:

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))
                        )
                )
        )
    }

}

不幸的是,只执行了“WarmUp”场景,完全跳过了“TestScn”:

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

我做错了什么?我正在使用最新的加特林版本 3.13.1

干杯!

gatling
1个回答
0
投票

在此复制加特林社区论坛上的答案

问题在于热身场景中的永远循环。 正如预期的那样,它使该场景的虚拟用户永远循环,因此它们永远不会完成,并且 Gattle 不会继续下一个场景。

也许您期望油门能够让该场景的所有虚拟用户在 15 秒后停止,但这不是油门的工作原理:限制在 15 秒后解除。

© www.soinside.com 2019 - 2024. All rights reserved.