JsonPatch check failing (incorrectly)

Awesome awesome :smiley:

Fixed! https://github.com/excilys/gatling/commit/1fdf7533c312f31d03a892dc42739b44f3b6c7c6

Will try to improve error reporting though.

Thanks for reporting!

Tested this morning - works great!

So … another thing … and I don’t know/think this is related to jsonPath per se.

So, I have an object that comes back like this:

{“count”:2,“result”:[{},{}]}

I’d like to write a check like this:

.check(jsonPath(“$.count”).saveAs(“count”))
.check(jsonPath(“$.result[*]”).count.is(session => session(“count”).as[Int]))

The second check causes an exception though:

[ERROR] [01/16/2014 07:59:17.368] [GatlingSystem-akka.actor.default-dispatcher-11] [akka://GatlingSystem/user/$c] key not found: count

java.util.NoSuchElementException: key not found: count

at scala.collection.MapLike$class.default(MapLike.scala:228)

at scala.collection.AbstractMap.default(Map.scala:58)

at scala.collection.MapLike$class.apply(MapLike.scala:141)

at scala.collection.AbstractMap.apply(Map.scala:58)

at io.gatling.core.session.SessionAttribute.as(Session.scala:38)

at com.weather.ssg.gatling.integration.IntegrationUtils$$anonfun$3.apply(IntegrationUtils.scala:133)

at com.weather.ssg.gatling.integration.IntegrationUtils$$anonfun$3.apply(IntegrationUtils.scala:133)

at io.gatling.core.session.package$RichExpression$$anonfun$map$extension$1.apply(package.scala:33)

at io.gatling.core.session.package$RichExpression$$anonfun$map$extension$1.apply(package.scala:33)

at io.gatling.core.check.CheckBase$$anonfun$check$2.apply(Check.scala:74)

at io.gatling.core.check.CheckBase$$anonfun$check$2.apply(Check.scala:73)

at io.gatling.core.validation.Success.flatMap(Validation.scala:30)

at io.gatling.core.check.CheckBase.check(Check.scala:73)

at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:33)

at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:32)

at io.gatling.core.check.Check$.checkRec$1(Check.scala:37)

at io.gatling.core.check.Check$.check(Check.scala:45)

at io.gatling.http.ahc.AsyncHandlerActor.checkAndProceed$1(AsyncHandlerActor.scala:229)

at io.gatling.http.ahc.AsyncHandlerActor.io$gatling$http$ahc$AsyncHandlerActor$$processResponse(AsyncHandlerActor.scala:245)

at io.gatling.http.ahc.AsyncHandlerActor$$anonfun$receive$1.applyOrElse(AsyncHandlerActor.scala:77)

at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498)

at akka.actor.ActorCell.invoke(ActorCell.scala:456)

at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237)

at akka.dispatch.Mailbox.run(Mailbox.scala:219)

at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386)

at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)

at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)

at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)

at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

To try to work around that, I make the same request twice. In the first request, I save the variable to the session. In the second request, I use the session variable in the second check.

The check fails, though.

The message is:

jsonPath($[0].doc.result[*]).is: (2) failed: found 2

My guess here is that count is being saved as a String.

Thanks for all the help and updates. I’m using gatling for a suite of integration tests to be used in our staging environment for a release that’s getting ready to roll out the door. It’s been very useful in this capacity.

–Spencer

Tested this morning - works great!

Cool!

I'd like to write a check like this:

.check(jsonPath("$.count").saveAs("count"))
.check(jsonPath("$.result[*]").count.is(session =>
session("count").as[Int]))

Won't work: saveAs updates haven't already been applied at this point.

jsonPath($[0].doc.result[*]).is: (2) failed: found 2

My guess here is that count is being saved as a String.

Yep

Use the new (syntax might change):
jsonPathTyped[Int]("$.count").saveAs("count")