gatling/scala question

Hi,
Sorry for the newbie question… I’ve searched the documentation and user group before posting…

I have custom code in an exec block :

.exec((s : Session) => {
if (condition)
{

http("request)
.post(…)

}

}

The http post request is not sent… i’ve turned on debugging and there is no mention there…

Another thing…
I’ve tried using s.setAttribute(“value”, …) in the custom code and later in an exec use EL “${value}” and it didn’t work either…

Any suggestions?

Thanks in advance,
Erik.

Hi again,

First question:
Nope, won’t work… 328.png

What you’re doing is defining a custom action where you create a new request builder. So? This request builder is never built and the resulting request executed.

What you have to do is use the doIf directive:
https://github.com/excilys/gatling/wiki/Structure-Elements#wiki-do-if

Second question:

Beware that, just like scenario elements builders, sessions are immutable.
https://github.com/excilys/gatling/wiki/Session#wiki-immutability
https://github.com/excilys/gatling/wiki/Session#wiki-functions

Meaning that session.setAttribute(“foo”, “bar”) will return a new Session instance that has to be returned. That’s why when executing a custom action, you’re expected to return a Session instance.

.exec{(session: Session) =>
session.setAttribute(“foo”, “bar”) // creates a new Session instance, and return it (in Scala, the result of the last operation in the block is returned)
}

Hope that helps,
Cheers,

Stéphane

2012/10/11 erik ashepa <erikash@gmail.com>