[gatling-charts-highcharts-2.0.0-M3a] HTTP Post body with JSON string from feeder removing quotes?

Relevant script pieces:

import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.Headers.Names._
import io.gatling.http.Headers.Values._
import scala.concurrent.duration._
import bootstrap._
import assertions._

class mchgreg extends Simulation {

val headers_1 = Map(
“Content-Type” → “application/JSON”
)

val userData = tsv(“test.tsv”).queue

val httpConf = http.baseURL(“http://myappurl.com/api”)

val scn = scenario(“Register user”)
.feed(userData)
.exec(
http(“POST registration”)
.post("/user/register")
.headers(headers_1)
.body(StringBody("${user}"))
)

setUp(scn.inject(atOnce(3 users))).protocols(httpConf)
}

My tsv file is super simple right now - it’s just a “user” column with the full JSON body to be submitted. At this point, though, it’s looking like the JSON body being posted is not including the quotes in the JSON string in my .tsv file. (for example, if my tsv file had a row with {“username”:“foo”, “email":"foo@bar.com”}, the endpoint seems to be receiving {username:foo,email:foo@bar.com}). The JSON is valid - I can submit it directly to the endpoint with Postman and it successfully registers the user.

Any thoughts on how to resolve this?

Thanks,
Hank

Hi,

The problem is that your file is not a valid tsv: see RFC 2.5: http://tools.ietf.org/html/rfc4180
“If fields are not enclosed with double quotes, then double quotes may not appear inside the fields.”

Either you enclose your JSON doc with double quotes and escape those inside with a backslash, or hack some Scala (here’s the starting point: https://github.com/excilys/gatling/blob/2.0.0-M3a/gatling-core/src/main/scala/io/gatling/core/feeder/SeparatedValuesParser.scala#L33).

Cheers,

Stéphane