Is it possible to save a random value from a JSON response? (Not all of them and then do a random)

81 views
Skip to first unread message

robert.ha...@hotmail.com

unread,
Sep 26, 2016, 2:27:01 AM9/26/16
to Gatling User Group
Hi!

I'm trying to test a webservice where the response is unpredictable. It might return 0 to 2000 items in the response. 
The repsonse contains among other things an url, and I would like to pick one at random.

I know that you could save all items with jsonPath("some json path").findAll.optional.saveAs("myurls") and then use them as ${myurls.random()}.
But since my response can contain up to 2000 urls which I thought would be inefficient to save to memory. Is it possible to pick one at random right from the response without saving them all to memory first?

Regards
Robert

Stéphane LANDELLE

unread,
Sep 26, 2016, 2:36:10 AM9/26/16
to gat...@googlegroups.com
Hi,

Will be featured in Gatling 3: https://github.com/gatling/gatling/issues/3088
For now, only in previews available for our support subscribers.

Regards,

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.

Vu Nguyen

unread,
Sep 26, 2016, 4:36:37 PM9/26/16
to Gatling User Group
Robert,

Could transform be a temporary solution until Gatling 3?

Example:
jsonPath("some json path").findAll.transform(Random.shuffle(_).head).optional.saveAs("rand_url")

robert.ha...@hotmail.com

unread,
Sep 29, 2016, 4:39:40 AM9/29/16
to Gatling User Group
Yeah, it works.

Thank you Vu!
Reply all
Reply to author
Forward
0 new messages