Using K6_STAGES env variable for a single scenario doesn't work

I have a single scenario in a script and when I try to override the stages using K6_STAGES env variable or via CLI, I get this error:

          /\      |‾‾| /‾‾/   /‾‾/   
     /\  /  \     |  |/  /   /  /    
    /  \/    \    |     (   /   ‾‾\  
   /          \   |  |\  \ |  (‾)  | 
  / __________ \  |__| \__\ \_____/ .io

ERRO[0000] There were problems with the specified script configuration:
        - executor default: function 'default' not found in exports 

Here is the scenario:

scenarios: {
    DeliveryOrder: {
      executor: 'ramping-vus',
      gracefulStop: '30s',
      stages: [
        { target: 2, duration: '20s' },
        { target: 2, duration: '30s' },
      gracefulRampDown: '30s',
      exec: 'DeliveryOrder',

ENV variable that I set: export K6_STAGES="30s:3,40s:4"

When unset the env variable, then the script works fine with the stages defined in the script itself.


Does this answer help?


Thanks for replying, @inanc

If the precedence is this: defaults < JSON config < script options < environment variables < CLI flags, then whatever I specify in environment variables should override script options right?
In that answer, they were using JSON config which has lower precedence then script options.
But in my case, env variables should have higher precedence over script options(I have the above given scenario in the script options). Hence I’m still not sure why the K6_STAGES is not overriding the script options.

Are we not supposed to have scenarios at all the script options in order for the env variable to work?

Hey @priyadharsini.ramu!

As the documentation says, the K6_STAGES is just a shortcut:

It is a shortcut option for a single scenario with a ramping VUs executor

That’s why it requires the default method to be presented. In your example, you define the scenarios scenarios, not the stages.

Let me know if that answers,