Scala / Gatling无法访问增量变量的值

时间:2018-08-03 13:33:04

标签: scala gatling

我正在尝试执行一个简单的任务(Scala和Gatling的新功能) 1)添加用户直到限制(在配置中定义)

2)在此周期内执行一组Get / Post请求

3)在每次迭代后添加用户(PreviousUserCount + 1)

4)在每次迭代结束时添加rendeVouz或暂停操作,以便在第一个用户执行请求时不会插入下一个用户。

我真的需要一些帮助。

代码:

//Increment Variable

var globalCounter = new java.util.concurrent.atomic.AtomicInteger(0)

val scn = scenario("Fast2000")
  .exec(session=>session.setAttribute("loopVar",globalCounter.getAndIncrement))
          .asLongAs(${loopVar}<availableUsers)
          .exec(fast2000.homePage)
          .pause(30 seconds)

setUp(
    scn.inject(rampUsers(${loopVar}) over(rampUserOver))
).protocols(httpProtocol)

错误:

15:17:34.571 [ERROR] i.g.c.ZincCompiler$ - C:\Gatling\user-files\simulations\Fast2000Test.scala:181: value setAttribute is not a member of io.gatling.core.session.Session
15:17:34.573 [ERROR] i.g.c.ZincCompiler$ -        .exec(session=>session.setAttribute("loopVar",globalCounter.getAndIncrement))
15:17:34.574 [ERROR] i.g.c.ZincCompiler$ -                               ^
15:17:34.574 [ERROR] i.g.c.ZincCompiler$ - C:\Gatling\user-files\simulations\Fast2000Test.scala:182: not found: value $
15:17:34.575 [ERROR] i.g.c.ZincCompiler$ -        .asLongAs(${loopVar}<availableUsers)
15:17:34.575 [ERROR] i.g.c.ZincCompiler$ -                  ^
15:17:34.575 [ERROR] i.g.c.ZincCompiler$ - C:\Gatling\user-files\simulations\Fast2000Test.scala:182: not found: value loopVar
15:17:34.575 [ERROR] i.g.c.ZincCompiler$ -        .asLongAs(${loopVar}<availableUsers)
15:17:34.575 [ERROR] i.g.c.ZincCompiler$ - 

0 个答案:

没有答案