k6 icon indicating copy to clipboard operation
k6 copied to clipboard

Ramping vus/stages drops 0 target stages at the end.

Open mstoykov opened this issue 3 years ago • 1 comments

Brief summary

Related to #2527.

If you have stages at the end with target 0, they will be dropped

export let options = {
  stages: [
    {duration: "1s", target 2},
    {duration: "1s", target 0},
    {duration: "1h", target 0},
  ]
}

will run for only 2s instead of 1h and 2s.

The usefulness of this behaviour is questionable but it's somewhat strange that we have stages (even with target 0) and we do not take them into account. Arguably this should at least print a warning or something.

The main usecase I can find is like in the case of #2527 trying to make certain that vus and vus_max gets zeroed out before the test exits.

k6 version

v0.38.2 and all before AFAIK

OS

all

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Run a script which has more than one sequential stage with target 0 at the end like

export let options = {
  stages: [
    {duration: "1s", target 2},
    {duration: "1s", target 0},
    {duration: "1h", target 0},
  ]
}

Expected behaviour

The test runs at least for the sum of all the stages durations

Actual behaviour

It stops after the first stage with target 0 at the end

mstoykov avatar May 12 '22 11:05 mstoykov

cc @na-- for when you have time. #1499 Would probably need to take this into account. Although I guess we have postponed working on that since forever ...

The PR I made seems to work and I haven't seen anything that it breaks, but I have probably just forgotten all the possible ways this can break :sob:

mstoykov avatar May 12 '22 11:05 mstoykov