Hello,
I’m using Gatling 2.2.0. I would like to perform a check on the size of the HTTP response. Based on a previous message in this group (from 2013), I’ve tried:
check(bodyString.transform(.map(.size)).matchWith(io.gatling.core.check.Matchers.greaterThan, 1))
However, this results in exceptions:
14:06:19.516 [ERROR] i.g.c.ZincCompiler$ - C:\tmp\test.scala:24: value size is not a member of Char
14:06:19.518 [ERROR] i.g.c.ZincCompiler$ - bodyString.transform(.map(.size)).matchWith(io.gatling.core.check.Matchers.greaterThan, 1)
14:06:19.519 [ERROR] i.g.c.ZincCompiler$ - ^
14:06:19.519 [ERROR] i.g.c.ZincCompiler$ - C:\tmp\test.scala:24: object Matchers is not a member of package io.gatling.core.check
14:06:19.519 [ERROR] i.g.c.ZincCompiler$ - bodyString.transform(.map(.size)).matchWith(io.gatling.core.check.Matchers.greaterThan, 1)
14:06:19.520 [ERROR] i.g.c.ZincCompiler$ - ^
14:06:19.559 [ERROR] i.g.c.ZincCompiler$ - two errors found
14:06:19.562 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
I tried “.length" instead of ".size” to no avail. What am I doing wrong? See below for the simulation file and output.
Thanks,
-Steve
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class TestSim extends Simulation {
val httpProtocol = http
.baseURL(“http://localhost:9000”)
val headers_0 = Map(
HttpHeaderNames.CacheControl → HttpHeaderValues.NoCache
)
val scn = scenario(“Test”)
.exec(
http(“request_0”)
.get("/some/path").asJSON
.headers(headers_0)
.basicAuth(“someone”,“password”)
.check(
bodyString.transform(.map(.size)).matchWith(io.gatling.core.check.Matchers.greaterThan, 1)
)
)
setUp(
scn.inject(atOnceUsers(1))
.protocols(httpProtocol))
}
$ c:\gatling2.2\bin\gatling.bat --simulations-folder C:\tmp --data-folder C:\tmp --simulation TestSim
GATLING_HOME is set to “c:\gatling2.2”
JAVA = ““C:\Program Files (x86)\Java\jdk1.8.0_91\bin\java.exe””
14:06:19.516 [ERROR] i.g.c.ZincCompiler$ - C:\tmp\test.scala:24: value size is not a member of Char
14:06:19.518 [ERROR] i.g.c.ZincCompiler$ - bodyString.transform(.map(.size)).matchWith(io.gatling.core.check.Matchers.greaterThan, 1)
14:06:19.519 [ERROR] i.g.c.ZincCompiler$ - ^
14:06:19.519 [ERROR] i.g.c.ZincCompiler$ - C:\tmp\test.scala:24: object Matchers is not a member of package io.gatling.core.check
14:06:19.519 [ERROR] i.g.c.ZincCompiler$ - bodyString.transform(.map(.size)).matchWith(io.gatling.core.check.Matchers.greaterThan, 1)
14:06:19.520 [ERROR] i.g.c.ZincCompiler$ - ^
14:06:19.559 [ERROR] i.g.c.ZincCompiler$ - two errors found
14:06:19.562 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
sbt.compiler.CompileFailed: null
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:105)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:95)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:95)
at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:95)
at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:168)
at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:94)
at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:142)
at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:84)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:66)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:64)
at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:31)
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:62)
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:61)
at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:89)
at sbt.inc.Incremental$.compile(Incremental.scala:61)
at sbt.inc.IncrementalCompile$.apply(Compile.scala:54)
at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:159)
at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:68)
at com.typesafe.zinc.Compiler.compile(Compiler.scala:201)
at com.typesafe.zinc.Compiler.compile(Compiler.scala:183)
at com.typesafe.zinc.Compiler.compile(Compiler.scala:174)
at com.typesafe.zinc.Compiler.compile(Compiler.scala:165)
at io.gatling.compiler.ZincCompiler$$anonfun$7.apply(ZincCompiler.scala:154)
at io.gatling.compiler.ZincCompiler$$anonfun$7.apply(ZincCompiler.scala:154)
at scala.util.Try$.apply(Try.scala:161)
at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:154)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:36)
at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)