我试图创建多个链并使用gatling按顺序执行它们。根据文档,这应该适用于1.3和我使用2.0但它仍然不适合我。我得到一个错误,找不到值exex。
package basic
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class BenchmarkSimulation extends Simulation {
val httpConf = http
.baseURL("http://127.0.0.1:9001")
.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 helloworld = exec(http("write-hello-world").get("/hello"))
val datetimenow = exec(http("write-datetime-now").get("/now"))
val scn = scenario("My Scenario").exec(helloworld, datetimenow)
setUp(scn.inject(ramp(1000 users) over (10 seconds))).protocols(httpConf)
}
确切的错误是这样的, ne-api / gatling / user-files / simulations / basic / BenchmarkSimulation.scala:17:not found:value exec
00:09:39.660 [ERROR] i.g.a.ZincCompiler$ - val helloworld = exec(http("write-hello-world").get("/hello"))
00:09:39.661 [ERROR] i.g.a.ZincCompiler$ - ^
00:09:39.663 [ERROR] i.g.a.ZincCompiler$ -
00:09:39.663 [ERROR] i.g.a.ZincCompiler$ - val datetimenow = exec(http("write-datetime-now").get("/now"))
00:09:39.663 [ERROR] i.g.a.ZincCompiler$ - ^
00:09:40.671 [ERROR] i.g.a.ZincCompiler$ - two errors found
Exception in thread "main" Compilation failed
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:105)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:98)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:98)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:98)
at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:155)
at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:97)
at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:138)
at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:86)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:30)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:28)
at sbt.inc.Incremental$.cycle(Incremental.scala:73)
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:33)
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:32)
at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:41)
at sbt.inc.Incremental$.compile(Incremental.scala:32)
at sbt.inc.IncrementalCompile$.apply(Compile.scala:25)
at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:146)
at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:70)
at com.typesafe.zinc.Compiler.compile(Compiler.scala:161)
at com.typesafe.zinc.Compiler.compile(Compiler.scala:142)
at io.gatling.app.ZincCompiler$.main(ZincCompiler.scala:111)
at io.gatling.app.ZincCompiler.main(ZincCompiler.scala)
Exception in thread "main" org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
at io.gatling.app.ZincCompilerLauncher$.apply(ZincCompilerLauncher.scala:54)
at io.gatling.app.SimulationClassLoader$.fromSourcesDirectory(SimulationClassLoader.scala:32)
at io.gatling.app.Gatling$$anonfun$15.apply(Gatling.scala:171)
at io.gatling.app.Gatling$$anonfun$15.apply(Gatling.scala:171)
at scala.Option.getOrElse(Option.scala:120)
at io.gatling.app.Gatling.start(Gatling.scala:171)
at io.gatling.app.Gatling$.fromMap(Gatling.scala:59)
at io.gatling.app.Gatling$.runGatling(Gatling.scala:80)
at io.gatling.app.Gatling$.main(Gatling.scala:54)
at io.gatling.app.Gatling.main(Gatling.scala)
答案 0 :(得分:3)
我认为你在你的类路径中混合了Gatling 1和Gatling 2库。
此外,“斜坡(1000个用户)超过(10秒))”是Gatling 1语法,它应该是“rampUsers(1000)over(10秒)”。
而且,只有在helloworld场景完成后才会开始执行datetimenow场景。
没有。 helloworld和datetimenow不是场景而是链(场景部分)。你只是将(实际上是chaing)合并为一个场景。如果你想在开始datetimenow之前等待所有用户完成helloworld,你必须编写2个不同的模拟,然后按顺序启动它们。