[Gatling 2.0.0-M3] What are HTTP API changes since Gatling 2.0.0-M2 ?

Hello

I’ve just updated my version of Gatling from 2.0.0-M2 to 2.0.0-M3 and I have several questions about the new http API.

  • What replaces httpConfig builder ? I used to call a HTTP config as follow :

    val httpConf = httpConfig.baseURL(“http://localhost:8080”)
    val scenario = scenario.protocolConfig(httpConf)

    But it seems that now there is no protocolConfig anymore. How can I recreate this behavior ?

  • How can I upload file using an action ? I used to upload a file as follow :

    val uploadDocument = exec(http(“Upload document”)
    .post("/myapi/document/")
    .upload(“archive”, “image_647.jpg”))

    But it seems that there is no upload method anymore. How I upload files now ?

Thank you for your answers

Regards,

Hi Vincent,

httpConfig is now plain http

Hi Stephane,

My request is a multipart form. Here is the request I do using curl to send my file :

curl -v -F ‘archive=@picture.jpg’ http://myapi/document/

Thanks for help

Regards,

So that would be:

val uploadDocument = exec(http(“Upload document”)
.post("/myapi/document/")
.headers(Map(CONTENT_TYPE → “multipart/form-data”))
.bodyPart(RawFileBodyPart(“archive”, “image_647.jpg”, “image/jpeg”)))

I finally managed to make it works (thanks Stephane !!!).

For my first issue, as httpConf doesn’t exist anymore, I call the whole url in http request as follow :

val getDocumentList = exec(http(“Get documents list”)
.get(http://localhost:8080/myapi/document/"))

For the upload, after some tries the following request works :

val uploadDocument = exec(http(“Upload document”)
.post("/myapi/document/")

.headers(Map(“Content_Type” → “multipart/form-data”))
.bodyPart(RawFileBodyPart(“image_647.jpg”, “image_647.jpg”, “image/jpeg”).withContentId(“archive”).withFileName(“image_647.jpg”))

Indeed, my API uses contentId to retrieve the file and need a file name to process the file.

Regards,

You misunderstood: httpConf still exists, that’s just the keyword that has been renamed from “httpConf” to “http”!

Indeed

But then how do you apply it to the simulation, as method protocolConfig has been removed ?

How man, you’re right. I missed that change! https://github.com/excilys/gatling/pull/1141

You no longer set up protocols per scenario, but per simulation:
https://github.com/excilys/gatling/wiki/Gatling-2#wiki-http-protocol