Skip to content

Option to toggle the scenario run #2780

@ppcano

Description

@ppcano

Feature Description

When using multiple scenarios, you might want to have a quick way to run the test with or without a particular scenario.

The suggested solution is to use environment variables to edit the scenarios object.

A dummy example:

const scenarios = {
  scenario_1: {
    executor: "shared-iterations",
    iterations: 1,
    vus: 1,
  },
  scenario_2: {
    executor: "shared-iterations",
    iterations: 1,
    vus: 1,
  },
  scenario_3: {
    executor: "shared-iterations",
    iterations: 1,
    vus: 1,
  },
};

if (__ENV.SKIP_SCENARIO1) {
  delete scenarios["scenario_1"];
}
if (__ENV.SKIP_SCENARIO2) {
  delete scenarios["scenario_2"];
}
if (__ENV.SKIP_SCENARIO3) {
  delete scenarios["scenario_3"];
}

export const options = {
  scenarios: scenarios,
};

Suggested Solution

Changed the initial proposal based on @pablochacin's suggestion

Provide an scenario common option to toggle the scenario execution.

export const options = {
  scenarios: {
    scenario_1: {
      executor: "shared-iterations",
      iterations: 1,
      vus: 1,
      skip: __ENV.SKIP_SCENARIO1,
    },
    scenario_2: {
      executor: "shared-iterations",
      iterations: 1,
      vus: 1,
      skip: __ENV.SKIP_SCENARIO2,
    },
    scenario_3: {
      executor: "shared-iterations",
      iterations: 1,
      vus: 1,
      skip: __ENV.SKIP_SCENARIO3,
    },
  },
};

And/or using the CLI:

k6 run --skip scenario_1,scenario_2 test.js

Already existing or connected issues / PRs (optional)

https://community.k6.io/t/how-to-execute-single-scenario-out-of-multiple-scenarios-in-a-script/1573

Metadata

Metadata

Assignees

No one assigned

    Labels

    evaluation neededproposal needs to be validated or tested before fully implementing it in k6featuretriageux

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions