将 Taurus 与 Gatling 一起使用失败并显示 "Exception in thread "main" io.gatling.core.session.el.ElParserException"

Using Taurus with Gatling fails with "Exception in thread "main" io.gatling.core.session.el.ElParserException"

我正在尝试 运行 Gatling with Taurus 来试验它,但它并不像预期的那样容易工作。

我有这个代码:

 execution:
   - executor: gatling
   scenario: sample

 scenarios:
   sample:
     script: tests/gatling/BasicSimulation.scala
     simulation: tests.gatling.BasicSimulation

并使用这个 gatling 模拟 scala 代码:

    package tests.gatling
    import io.gatling.core.Predef._
    import io.gatling.http.Predef._
    import scala.concurrent.duration._
    class BasicSimulation extends Simulation {
      val httpConf = http
        .baseURL("http://computer-database.gatling.io")
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
        .doNotTrackHeader("1")
        .acceptLanguageHeader("en-US,en;q=0.5")
        .acceptEncodingHeader("gzip, deflate")
        .userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")
      val scn = scenario("BasicSimulation")
        .exec(http("request_1")
        .get("/"))
        .pause(1)
      setUp(
        scn.inject(atOnceUsers(1))
      ).protocols(httpConf)
    }

当我 运行 它是这样的:

bzt gatling.yml

它以错误结束:

08:13:02 ERROR: Child Process Error: Gatling tool exited with non-zero code: 1
...
Gatling STDERR:
Exception in thread "main" io.gatling.core.session.el.ElParserException: Failed to parse text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 with error '[B cannot be cast to [C'
    at io.gatling.core.session.el.ElCompiler.parseEl(ElCompiler.scala:249)
    at io.gatling.core.session.el.ElCompiler$.parse(ElCompiler.scala:171)
    at io.gatling.core.session.el.ElCompiler$.compile(ElCompiler.scala:174)
    at io.gatling.core.session.el.package$El$.el$extension(package.scala:26)
    at io.gatling.core.ValidationImplicits.stringToExpression(ValidationImplicits.scala:48)
    at io.gatling.core.ValidationImplicits.stringToExpression$(ValidationImplicits.scala:48)
    at io.gatling.core.Predef$.stringToExpression(Predef.scala:22)
    at tests.gatling.BasicSimulation.<init>(BasicSimulation.scala:12)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
    at java.base/java.lang.Class.newInstance(Class.java:558)
    at io.gatling.app.Runner.run0(Runner.scala:79)
    at io.gatling.app.Runner.run(Runner.scala:64)
    at io.gatling.app.Gatling$.start(Gatling.scala:59)
    at io.gatling.app.Gatling$.fromArgs(Gatling.scala:43)
    at io.gatling.app.Gatling$.main(Gatling.scala:35)
    at io.gatling.app.Gatling.main(Gatling.scala)
...

我前一段时间遇到了同样的问题,根本原因是我使用的是 jdk 9 ,我降级到 8 并且它有效。

我试过你的代码,它适用于 jdk 8

我无法使用最新的 Taurus v1.12.1

重现您的问题
dt@aldan:/tmp> bzt gatling.yml 
09:32:29 INFO: Taurus CLI Tool v1.12.1
09:32:29 INFO: Starting with configs: ['gatling.yml']
09:32:29 INFO: Configuring...
09:32:29 INFO: Artifacts dir: /tmp/2018-08-21_09-32-29.122174
09:32:29 INFO: Preparing...
09:32:30 INFO: Starting...
09:32:30 INFO: Waiting for results...
09:32:31 INFO: Waiting for finish...
09:32:43 WARNING: Please wait for graceful shutdown...
09:32:43 INFO: Shutting down...
09:32:43 INFO: Post-processing...
09:32:43 INFO: Test duration: 0:00:13
09:32:43 INFO: Samples count: 2, 0.00% failures
09:32:43 INFO: Average times: total 0.065, latency 0.000, connect 0.000
09:32:43 INFO: Percentiles:
┌───────────────┬───────────────┐
│ Percentile, % │ Resp. Time, s │
├───────────────┼───────────────┤
│           0.0 │         0.045 │
│          50.0 │         0.045 │
│          90.0 │         0.085 │
│          95.0 │         0.085 │
│          99.0 │         0.085 │
│          99.9 │         0.085 │
│         100.0 │         0.085 │
└───────────────┴───────────────┘
09:32:43 INFO: Request label stats:
┌──────────────────────┬────────┬─────────┬────────┬───────┐
│ label                │ status │    succ │ avg_rt │ error │
├──────────────────────┼────────┼─────────┼────────┼───────┤
│ request_1            │   OK   │ 100.00% │  0.085 │       │
│ request_1 Redirect 1 │   OK   │ 100.00% │  0.045 │       │
└──────────────────────┴────────┴─────────┴────────┴───────┘
09:32:43 INFO: Artifacts dir: /tmp/2018-08-21_09-32-29.122174
09:32:43 INFO: Done performing with code: 0
dt@aldan:/tmp> 

其他环境详细信息:

首先尝试将 Taurus 升级到最新版本,例如:

pip install --upgrade bzt

如果没有帮助,您可以尝试 building Gatling script from YAML config, check out How to Load Test with Gatling and Taurus 指南了解更多详情