is it possible to use "executor"in k6 options in default scenario? that is without specifiying "scenarios"

36 Views Asked by At

I am experimenting with k6. I want to know if using executor in default scenarios is posssible?

my options object look like below. Note "Executor" property

    export let options = {
  vus: 1,
  duration: '1s',
  executor:'constant-vus'
}

when running k6 script i get Warning message WARN[0000] There were unknown fields in the options exported in the script error="json: unknown field "executor""

the documentation doesn't say anything about using executors in "default scenario" so i am raising this question to the community. please let me knowenter image description here

1

There are 1 best solutions below

0
knittl On

The executor property is only available inside scenarios. If you don't provide an exec function explicitly, the default function will be used.

export let options = {
  scenarios: {
    default: {
      executor:'constant-vus',
      duration: '1s',
      vus: 1
    }
  }
};

export default function() {
  console.log('this is executed once per second');
}

This is covered in the constant-vus executor example

Note that constant-vus is the default when not using any scenarios and specifying duration and vus. So the above is equivalent to the following config:

export let options = {
  duration: '1s',
  vus: 1
};

Which is exactly the options from your question, minus the executor itself (but it still uses the constant-vus executor).