Initial config data

Hey guys, how are you doing??

Gatling looks like a really nice tool. I’m trying to use it for our project. However I’m running into this problem:
It happens that I have some configuration data which will be used to start the simulation. For example, I might have some date, let’s call it dateX. But I want to prepare dateX beforehand. So I was planning to have some kind of initialization block and call session.set(“dateX”, dateX).

I tried doing:

scenario(“my scenario”)

.exec { session: Session => { session.set(“dateX”, calculatedDate); value2Success(session) } }

.http(“my request).get(”"“http://host/service/operation?dateX=${dateX}”"")

But when I run it, I’m getting:

11:29:24.269 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘dateX’ is defined

Can you please tell me if what I’m trying to achieve is doable and where am I messing up? Can you also think in some other way?

Thanks!
Alex

Hi,

Thanks.

The “session” object is immutable, so, at least, you should change your code so that you have that :

.exec { session: Session => { val sessionWithDateX = session.set(“dateX”, calculatedDate); value2Success(sessionWithDateX) } }

cheers

nicolas

value2Success is an implicit, meaning that it is (should in most cases actually) be automatically applied as soon as you return something that isn’t a Validation.

So .exec(session => session.set(“dateX”, calculatedDate)) should work well