In my loadtest i have the following scenario every VU executes:
Login, establishes the usersession, creates a process for this session on the server
doStuff
Logout, quitting the session, terminates the process of the usersession on the server
The thing is, when ramping down,the VUs are not guaranteed to do the logout, which results in having a lot of processes still running on the server.
Is there a way to have a setup and teardown function every VU executes per iteration, or at least a workaround for that?
With the addition of Arrival Rate Based VU Execution we would get what we internally call uninterruptible iterations which basically will not be stopped when ramping down or the test ends.( They will actually have a timeout but it will be configurable :)). This is currently in active development and I am waiting for a PR to get open this week, hopefully.
There was already a bit of refactoring of the configuration around this.
Unfortunately I can’t tell you if that PR will be merged this week(very unlikely), next week(I hope) or a month from now. Even less likely is for us to get a stable release right after this, as there will be things to fix and we would need a lot of actual testing before we decide that it is release worthy.
This issue can probably be extend with something like a per iteration setup/teardown, but this will probably not get much attention before the Arrival rate based execution is done :(.
I suppose logging in setup() and logging out in teardown() is not going to help you as you will get too many processes on the server.
As far as I know there is nothing currently in k6 that will help you.
You can try to not rampdown (if this is possible for you) but even then at the end logouts may not be ran which means that your application will need to timeout them (I suppose it already does this). Maybe lowering the timeout for the tests will help you?
If you have any suggestion about something that can be done to help you can always write an issue or add to one the already open ones