newbie gatling dumb json validation question

64 views
Skip to first unread message

rtm...@googlemail.com

unread,
Dec 8, 2016, 10:03:37 AM12/8/16
to Gatling User Group
Hi all, 
I've done my first bit of gatling and I need to verify the results of parsed json. I did a lot of searching and couldn't see how, but I suspect I was missing the obvious (it was getting very late). 
My gatling code now doesn't work due to 2nd party problems, which hopefully will be fixed soon, so I can't run or test anything but if anyone can show me how to get this working it will make gatling a lot more interesting to my colleagues, and we need a load tester soon.

OK, my code is 

val getUnmodifiedAttribs =
     exec(http("get unmodified attribs")
       .get("http://localhost:9000/files/${fileCreatedID}/Attributes")
       .check( jsonPath("$[*].value").findAll.saveAs("tmpjson") )
       .check( jsonPath("$[*].value").count.is(8) )


The above verifies the json is length 8. I need next verify it contains expected results, preferably in scala as the checks may get very involved. 

If the answer is on the web please point me at. I repeatedly read the docs but couldn't see it. So sorry if this is obvious to everyone else, but how is this done?

cheers

jan

rtm...@googlemail.com

unread,
Dec 8, 2016, 4:54:29 PM12/8/16
to Gatling User Group
I'd really appreciate some pointers. If necessary I'll do it in WGet scripts; it has to be done somehow, but i'd prefer using a decent tool. 
If it's a particularly stupid question, forgive me, but I did do a lot of searching before posting here.

cheers

jan

Stéphane LANDELLE

unread,
Dec 8, 2016, 6:59:58 PM12/8/16
to gat...@googlegroups.com
If you need complex validation, you'll probably need to write your own Validator.

Now, this is a community mailing list. If you need fast and accurate answer from the experts and what you can get from good willed community members doesn't meet your needs, we at GatlingCorp can help with professional services.

Stéphane Landelle
GatlingCorp CEO


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rtm...@googlemail.com

unread,
Dec 9, 2016, 2:33:47 AM12/9/16
to Gatling User Group
Thanks, when looking around I did see a blog where someone wrote something similar, but I couldn't handle that level of scala yet - nor quite see the need. I just want to escape to scala, with the value retrieved, turn it into a boolean and have Gatling's .check proceed based on that. 

If that can't be done in Gatling, I need to know so I can switch to something else. I find it impossible to imagine that it can't be easily done given Gatling's front-end is just chained library calls.

It did occur to me, too late to try, that a transformer might be the way to do it?

cheers

jan
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.

Stéphane LANDELLE

unread,
Dec 9, 2016, 3:37:04 AM12/9/16
to gat...@googlegroups.com
Once again, yes, it's possible and not that complicated.
Just use validate, pass it a Validator, which is basically a function from Option[T] to Validation[Option[T]]

If you can write a function from T to Boolean, you should able to write such method.


To unsubscribe from this group and stop receiving emails from it, send an email to gatling+unsubscribe@googlegroups.com.

Stéphane LANDELLE

unread,
Dec 9, 2016, 3:38:28 AM12/9/16
to gat...@googlegroups.com
Another solution would be to use transform but then you'd only be able to save the transformed value.

Stéphane Landelle
GatlingCorp CEO


rtm...@googlemail.com

unread,
Dec 9, 2016, 6:07:27 AM12/9/16
to Gatling User Group
Thanks so much! I'll try to get to this ASAP

cheers

jan
Reply all
Reply to author
Forward
0 new messages