I have a csv file like below.
id1,id2
123,-8
124,-9
125,-10
I try to use the CSV feeder to do a POST request for each of the lines in the CSV file. The POSTs don’t work. However, GETs using the same feeder file work. Is my syntax wrong? Or is it not the correct way to do POSTs using feeders?
Below is my class.
package test
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class FeederSimulation extends Simulation {
val ids = csv("ids.csv").random
val httpConf = http
.baseURL("http://localhost:3001/api")
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
.doNotTrackHeader("1")
.acceptLanguageHeader("en-US,en;q=0.5")
.acceptEncodingHeader("gzip, deflate")
.userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")
val scn = scenario("post-example")
.feed(ids)
.exec(http("post-example")
.post("/create")
.body(StringBody("""{"id1":{id1}, "id2":{id2}""")).asJSON)
setUp(scn.inject(atOnceUsers(1)).protocols(httpConf))
}
The below one for GETs does work:
val scn = scenario("get-example")
.feed(ids)
.exec(http("get-example")
.get("/someUrl")
.queryParam("id1", "${id1}")
.queryParam("id2", "${id2}")