0

I have a JSON like this:

[
  {
    "eventType": "customEvent",
    "deviceID": "e190c022-f7b1-4b34-b5ba-a5ec249c6dc9",
    "platform": "android",
    "appVer": "1.0.0"
  },
  {
    "eventType": "customEvent2",
    "deviceID": "e190c022-f7b1-4b34-b5ba-a5ec249c6dc9",
    "platform": "android",
    "appVer": "1.0.0"
  }
]

I'm trying to create a simple gatling scenario where I could simulate a number of users firing either of two JSON objects. A sample url for each virtual user would be as follows http://website.com/?eventType=customEvent&deviceID=e190c022-f7b1-4b34-b5ba-a5ec249c6dc9&platform=android&appVer=1.0.0

How can I pass all parameters from JSON to my gatling scenario?

Please help, I'm very bad at Scala.

SergioLeone
  • 734
  • 1
  • 10
  • 24

1 Answers1

0

After lots of googling and trials finally made it work. This can be done as follows:

[
  {
    "event": {
      "eventType": "eventName",
      "deviceID": "e190c022-f7b1-4b34-b5ba-a5ec249c6dc9",
      "platform": "android"
    }
  }
]

And code:

private val event = scenario("my-scenario")
    .foreach(jsonFeed, "sim", "index") {
      exec(
        http("send-sim-{index}")
          .post("/?eventType=${sim.event.eventType}&deviceID=${sim.event.deviceID}&platform=${sim.event.platform})
          .check(status.is(200))
      )}
SergioLeone
  • 734
  • 1
  • 10
  • 24