Skip to content

K6 Executor: Scenario defined within K6 .js only executing 1 iteration #1791

@asos-benpearson

Description

@asos-benpearson

Hi,

When running a K6 test through Taurus and having the scenario defined within the K6 script itself instead of the Taurus yml file, only 1 iteration is completed before shutting down the test.

Example K6 Test.

import http from "k6/http";
import { check, sleep } from "k6";

export const options = {
  scenarios: {
    POC: {
      executor: 'constant-vus',
      vus: 20,
      duration: '3m',
    },
  },
  tags: {
    name: 'GET-Request',
  }
};

export default function () {
  let res = http.get('https://www.google.com');
  
  check(res, {
    "status was 200": (r) => r.status == 200
  })
  sleep(1);
}

Example Taurus Yml

execution:
- executor: k6
  scenario: POC

scenarios:
  POC:
   script: K6-Demo.js  # has to be a valid K6 script

settings:
  artifacts-dir: Artifacts/POC_LoadTest-K6/%Y-%m-%d_%H-%M-%S-%f/

modules:
  console:
    disable: true

On inspecting the bzt log I noticed the following '--iterations 1' is added to the cmdline output

[2023-11-27 11:58:44,143 DEBUG root] Executing shell: ['k6', 'run', '--out', 'csv=C:\\Source\\K6 Test\\K6-Defined-Scenario\\Artifacts\\POC_LoadTest-K6\\2023-11-27_11-58-43-074044\\kpi.csv', '--iterations', '1', 'C:\\Source\\K6 Test\\K6-Defined-Scenario\\K6-Demo.js'] at C:\Source\K6 Test\K6-Defined-Scenario

I would expect Taurus to just execute the K6 Run command with the specified file, which would then use the scenario from within the K6 test, rather than defaulting iterations to 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions