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

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

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,

Robert,

Could transform be a temporary solution until Gatling 3?
http://gatling.io/docs/2.2.2/http/http_check.html#transforming

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

Yeah, it works.

Thank you Vu!

mandag 26. september 2016 22.36.37 UTC+2 skrev Vu Nguyen følgende: