Interpolation in body()

Hi,

I’m having trouble getting session variable interpolation working when using “body()” in the DSL (with current master). e.g.

val createUsers = scenario(“Create user”)
.feed(feeder)
.exec((s: Session) => {
println (“Creating user " + s.getAttribute(“username”))
println (“Session " + s)
s
})
.exec(
http(“createUser”)
.post(”/User”)
.header(“Authorization”, “Bearer ${access_token}”)
.header(“Accept”, “application/json”)
.header(“Content-Type”, “application/json”)
.body("""{“name”:{“givenName”:“Joe”,“familyName”:“User”,“formatted”:“Joe User”},“userName”:"${username}",“emails”:[{“value”:"${username}@blah.com"}]}""")
.check(status.is(201))
)

Then I get:

Creating user joel1
Session com.excilys.ebi.gatling.core.session.Session@54014944
13:03:38.532 [akka:event-driven:dispatcher:global-9][INFO ] c.e.e.g.h.a.HttpRequestAction - Sending Request ‘createUser’: Scenario ‘Create user’, UserId #1
13:03:38.535 [akka:event-driven:dispatcher:global-9][DEBUG] c.e.e.g.h.r.HttpRequest - Request created: http://localhost:8080/uaa/User, body data: {“name”:{“givenName”:“Joe”,“familyName”:“User”,“formatted”:“Joe User”},“userName”:"${username}",“emails”:[{“value”:"${username}@blah.com"}]}

so it doesn’t seem to be doing the replacement.

Looking at AbstractHttpRequestWithBodyBuilder, I can see other places where interpolation is called, but not when setting a body.

Is there some way I can get the data in there?

Cheers,

Luke.

P.S. What do you guys do for tests :wink: ? I’m loathe to submit pull requests when there aren’t any tests in the build. Do you run a separate test suite somewhere?

Hi Luke,

I’ve pushed the fix in the master and closed the issue :
https://github.com/excilys/gatling/issues/404

Regarding the tests, ahem, hum, well…
We have integration tests with the Cloud Foundry app and a rails app, but nothing very clean and stable and we haven’t published them.
And honestly, I didn’t anticipate that people would build the master and play with it so soon…

We do want to have automated tests, but we still have to puzzle how.
What we’re considering is :

  • Akka TestKit
  • Have a look at how tests are done in AsyncHttpClient
  • Have a maven plugin for embedding and launching Gatling (we plan on doing this anyway) and run an embedded server.
    We definitively want to have this before releasing the 1.1.
    Like always, the problem is time 328.png
    Do you have any idea on the topic?

Anyway, thanks for testing and reporting, that’s a big help!

Cheers,

Stéphane

2012/2/9 Luke Taylor <munkymisheen@gmail.com>

Thanks, Stéphane :-).

I’ve also sent a pull request as there was an issue with overmatching of the interpolated value within a JSON string.

I think it makes sense to at least have some unit tests (for things like this, for example), to give some confidence that things are still working as you expect. Obviously you quite easily put together integration tests with gatling :-), but they’d need a test app to run against which would could cater for the different test cases you want to cover. If your other app can be run standalone and had a gatling test suite, I guess you can just ask users to run the tests for that before making changes.

Cheers,

Luke

I completely agree.
We’ll have some Spec2 tests for Helpers and other kinds of standalone components and publish a clean webapp.
We’ll work on this next week.

Cheers,

Stéphane

2012/2/9 Luke Taylor <munkymisheen@gmail.com>