variable length pause

Hi,

I’d like to have a pause in my simulation that can very in length; I don’t want it to be random, though, I would like for it to call a function and use the return value for the length of the pause.

My best guess so far was to use a “session function”, where I change the pause to an exec((session:…) => …), and then I just do a “Thread.sleep” inside my function.

However, I’m not sure if “Thread.sleep” is functionally equivalent to what “pause” does. Some of these sleeps will be really long (e.g. 30 minutes), and I’m worried about the HTTP connection timing out while I’m doing my sleep.

Any ideas on a better solution?

Thanks
Chris

Thread.sleep() is something you should absolutely avoid in an async application. One thread is not associated to a specific user.

Isn’t the .pauseCustom(() => Long) element doing what you want ?

I can’t remember, which version of Gatling are you using? With the 2.0, the signature is pauseCustom(delayGenerator: Expression[Long]), so, you have access to the session.

cheers
Nicolas

Oh, wow, I completely missed the “pauseCustom” function in the docs. That looks like it will do exactly what I want. Thank you!

Ah… so, no way to access the session in a pauseCustom in 1.5.x?

Nope, Gatling 1.5 EL is not powerful enough and can only resolve Strings (where a pause is a Duration). That’s why they were completely redesigned in version 2.

Cool, thanks. I think I managed to work around it with some session functions and “doIfs”.

I look forward to switching us up to v2 sometime in the not-too-distant future!

That’s a workaround indeed, good idea.
Let me know if you need help migrating.

How stable do you consider the 2.0 API at this point?

Pretty stable I’d say. I think the next milestones will focus more on features and less on refactoring (except the recorder).