我正在尝试与金牛座(Gaurus)一起运行加特林(Gatling)进行试验,但是它的运行并不像预期的那么容易。
我有此代码:
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)
...
答案 0 :(得分:1)
前段时间我遇到了同样的问题,根本原因是我使用的是jdk 9,我降级为8并可以正常工作。
我尝试了您的代码,它在jdk 8上对我有效
答案 1 :(得分:0)
我无法使用最新的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,请查看How to Load Test with Gatling and Taurus指南以了解更多详细信息