How do I write a custom Gatling feeder based off a JSON file that has certain values that are stubbed and need to be replaced before being sent? For example
{"payloads":[
{"groupId":"<GUID>", "epoch":<TIME>, "report":"somethingInteresting1"},
{"groupId":"<GUID>", "epoch":<TIME>, "report":"somethingInteresting2"},
{"groupId":"<GUID>", "epoch":<TIME>, "report":"somethingInteresting3"}
]}
jsonFile("/opt/gatling/user-files/simulation/cannedPayloads.json")
won't work I think because it's not actually valid JSON in the file. I've tried:
val jsonFileContents = Source.fromFile("/opt/gatling/user-files/simulation/cannedPayloads.json").getLines.mkString
.replaceAll("<GUID>", java.util.UUID.randomUUID().toString())
.replaceAll("<TIME>", Instant.now().toEpochMilli().toString())
val feeder = JsonPath.query("$.payloads[*]", jsonFileContents).right.get.toArray.circular
val scn1 = scenario("CannedTestSimulation").exec(feed(feeder).exec(
http("to ingestion").post(url).body(StringBody("$")).asJSON
)