Feed scenarios with JSON received from a REST service

1,138 views
Skip to first unread message

Jérôme Mars

unread,
Jan 5, 2015, 9:20:06 AM1/5/15
to gat...@googlegroups.com
Happy new year everybody.

I'm bugging (me) on something...

Our way of feeding data has been decided, we can't use csv file either json file (too static, to map on any database, without having each time job to do). We will write some REST Services to interrogate the databases (all intelligence stays on the application-server side, nothing is written in gatling except it's own scripts). 
These REST servicies return JSON object in String format.

Example : 
  private val usersData: String = RestUrlCall.getRestContent("http://127.0.0.1:8888/bench/benchFeeder/testDataFeeder")

Which may returns, depending on databases these type of string, for examples :
[{"id":1144,"name":"NEDOQUE MAX"},{"id":1080,"name":"BLOCQUEAU JULIE"},{"id":1081,"name":"DIETY LILY"}]

I Parse this with Jackson  :
  val jObject = Jackson.parse(usersData)
(which works fine, I got an ArrayList<LinkedHashMap> in return)

And here is where I'm stucked...

How to feed my scenario with these data?
How to transform my parsed String into FeederBuilder[_] ?

Hope the question is not that stupid....

Thank you.

Abhinav Gogna

unread,
Jan 5, 2015, 11:35:30 AM1/5/15
to gat...@googlegroups.com
Jerome,

There are multiple ways to achieve this.

1) You can build a custom feeder - http://gatling.io/docs/2.1.2/session/feeder.html
2) Here is a JSON feeder - http://gatling.io/docs/2.1.2/session/feeder.html#json-feeders

Jérôme Mars

unread,
Jan 5, 2015, 12:22:17 PM1/5/15
to gat...@googlegroups.com
Thank you for helping me.

1) I really thought it was THE solution, I tried.... but obviously I did not understand how this works.... I couldn't write it...
2) I already looked at the JSON feeder but they have to be either in a diskFile or downloadable through an URL, so I can use none of them...

Do someone has en example of a custom build feeder please?

Thank you.

Abhinav Gogna

unread,
Jan 5, 2015, 1:51:11 PM1/5/15
to gat...@googlegroups.com
JsonFeeder looks straightforward and simple Can you tell me how you tried it? Can you share your simulation?

Abhinav Gogna

unread,
Jan 5, 2015, 2:01:45 PM1/5/15
to gat...@googlegroups.com
The simplest way to implement it would be something like the following:

val myFeeder = jsonUrl("http://127.0.0.1:8888/bench/benchFeeder/testDataFeeder")

object test {
val myLoadTest = feed(myFeeder)
                 
.exec(http("name of test").get("<your load test app url>")
                 
.queryParam("id", "${id}") // id from your json array
                 
.queryParam("name", "${name}") // name from your json array.

But since I don't know what you are trying to do with the data, I am not sure if this will work.

Jérôme Mars

unread,
Jan 6, 2015, 4:43:36 AM1/6/15
to gat...@googlegroups.com
Holly SH### it was so simple that I never tryed it this way ..... :(
So you just solve my problems... 

Thank you very much.
( I'm quite disapointed I didn't find it on my own, but... )

Jerome

Stéphane Landelle

unread,
Jan 6, 2015, 5:01:59 AM1/6/15
to gat...@googlegroups.com
@Abhinav Nice job helping here, thanks a bunch!

--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhinav Gogna

unread,
Jan 6, 2015, 7:54:32 PM1/6/15
to gat...@googlegroups.com
Just paying it forward :)

Sunil Jacob

unread,
Jun 29, 2017, 12:15:14 PM6/29/17
to Gatling User Group
Hi Abhinav,

Could you please help me on the Json Feeder?
Reply all
Reply to author
Forward
0 new messages