Gatling 在一系列场景中制作一个场景 运行 一次

Gatling make one scenario run once in a chain of scenarios

我有一个场景,我必须执行某些步骤。但我不希望用户多次登录。所以我链接了场景,但登录仍然发生多次。有什么办法可以限制链的一部分只运行一次吗?

class CreateUserSimulation extends Simulation {
val login = Login.getExec()
val userCreate = UserCreate.getExec("basic")
val userJourney = scenario("User Journey")
    .exec(login)
    .exec(userCreate)

setUp(      
    userJourney.inject(constantConcurrentUsers(10) during (2 seconds))
).protocols(Params.httpProtocol)

}

您需要创建一个变量来说明您是否在系统中

val userJourney = scenario("User Journey")
.exec(_.set(isLogin, "0"))
.doIf(session => session("isLogin").as[String].equals("0")) {
  exec("login")
    .exec(_.set("isLogin", "1"))
}
.exec(userCreate)