I have a scenario with three basic exec steps:
- Add some stuff to the session
- Post some data
- get some data for verification
Running code similar to this:
1 val simpleScenario = scenario("DEA Promotions Extended") 2 .feed(ssv(getFilename()).circular) 3 .exec{session => 4 session.set("x", "y") 5 } 6 .exec(CreatePromotion.postForStage(this.stage)) // produces: "Write DEA Promotion permission" 7 .exec{ 8 http("Lookup detailed DEA Promotion permission") 9 .get(...) 10 .headers(...) 11 .check(status.is(200)) 12 13 }
I’ve got my two operations neatly shown in the overview while the scenario runs:
https://gatling.io/docs/current/general/scenario/#exec
Warning
Gatling DSL components are immutable ActionBuilder
(s) that have to be chained altogether and are only built once on startup. The results is a workflow chain of Action
(s). These builders don’t do anything by themselves, they don’t trigger any side effect, they are just definitions. As a result, creating such DSL components at runtime in functions is completely meaningless. If you want conditional paths in your execution flow, use the proper DSL components (doIf
, randomSwitch
, etc)
Hi Stéphane,
I’ve read this paragraph many times, but still don’t understand how this relates to the issue i’m facing at the moment.
The ability to pass-through the session is mentioned above the passage you refering to:
https://gatling.io/docs/2.3/general/scenario/#exec
So what am i doing wrong here?
salut,
Matthias
7 .exec{ session =>
8 http(“Lookup detailed DEA Promotion permission”)
You’re exactly doing what is described as not working. You can’t create http request inside session functions.
Thanks for clarifying this!
I was mislead by the fact that the http call was actually running …
It might be a good idea to mention this in the exec documentation example as something which won’t work.
So how am i supposed to get a reference to the session in an followup step?
I was mislead by the fact that the http call was actually running ...
The builder gets instanciated, but no HTTP request is actually sent.
It might be a good idea to mention this in the exec documentation example
as something which won't work.
It's already mentioned in this very same page:
exec { session =>
if (someSessionBasedCondition(session)) {
// just create a builder that is immediately discarded, hence
doesn't do anything
// you should be using a doIf here
http("Get Homepage").get("http://github.com/gatling/gatling"\)
}
session}