Using stages from Environment Variable

Hello,

Running into an issue when trying to use stages with an Environment variable. It does not set max users or iterations as it does when using options variable inside test script.

docker run -e K6_STAGE="10s:10,2m:30,30s:0" -i loadimpact/k6 run --include-system-env-vars=true - <script.js

  execution: local--------------------------------------------------]   servertor
     output: -
     script: -

    duration: -, iterations: 1
         vus: 1, max: 1

sets iterations to 1 and max to 1. This causes the test not to run through the full set of stages and finish early. vs

export let options = {
    stages: [
        { duration: '10s', target: 10 },
        { duration: '2m', target: 30 },
        { duration: '30s', target: 0 },
    ]
};

sets iterations to - and max to 30

  execution: local--------------------------------------------------]   servertor
     output: -
     script: -

    duration: -, iterations: -
         vus: 1, max: 30

I could set max manually to the required value, but have no idea how to set iterations to the equivalent of -.

Any advice appreciated

1 Like

Hi @paulfairless

the correct env variable is K6_STAGES not K6_STAGE :wink:

Also, I am pretty sure you don’t need --include-system-env-vars=true, it is already true for k6 run, but you will need it for k6 cloud as it is false there :slight_smile:

Thanks, I should have just tried that i suppose.

The github readme has examples using K6_STAGE which is how i was was getting thrown off the scent.

All works as expected now, thanks for the help

1 Like

:man_facepalming: sorry about that, we’ll fix the README :blush:

1 Like

updated in eebe92db

1 Like