Hi,
I’m setting up a load test of a Scala 2.10 Spray project, using Gatling 2.0.0-SNAPSHOT. I used the recorder to setup a basic scenario hitting my REST service, which when replayed works fine. I need to use the Scalate template feature however to tweak each request with some dynamic data, and so I switched to using the overloaded fileBody call which works with a Scalate template:
val scn = scenario(“Scenario1”)
.feed(data)
.exec(http(“request_1”)
.post("/event")
.fileBody(“event”, Map(“user” → “${user}”))
.check(status.is(202))
)
When using the template, I was not getting any request hitting the spray server. I turned on debugging and saw that a connection is made from Gatling, but it never receives the full request and logs it (as it does fine when using a simple file body with no template). So I hooked up Gatling to use a Charles proxy, and captured the event on the wire. What I found was that when using the Scalate overload, the body of the request is missing; it is empty. When using the normal fileBody, it is present and correct. Everything else is identical in both (headers etc, including correctly set Content-Length).
I traced through everything with the debugger, and found that the Scalate template is resolved perfectly and the values are substituted in to make the body that I’m expecting, but at the last minute the body is stripped out, before the request is sent on the wire. It seems like this is occurring in AbstractHttpRequestWithBodyAndParamsBuilder:
if (paramsAttributes.uploadedFiles.isEmpty)
requestBuilder.flatMap(configureParams)
else {
requestBuilder.flatMap(configureStringParts).flatMap(configureFileParts)
}
With the overload, it hits the first condition, and then does a:
HttpHelper.httpParamsToFluentMap(paramsAttributes.params, session).map(requestBuilder.setParameters)
Where this ultimately hits:
request.stringData = null;
in resetNonMultipartData() of RequestBuilderBase.
So it appears that the string body is stripped out
If there is a work around (or I’ve missed something) that would be great to know, otherwise hope this helps fix the issue. I realise I’m on the edge using the latest snapshot, but want to use the awesome power of Gatling on a Scala 2.10 project
Cheers
Tim