Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
asos-benpearson opened this issue Nov 27, 2023 · 1 comment · May be fixed by #1797
Open

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

asos-benpearson opened this issue Nov 27, 2023 · 1 comment · May be fixed by #1797

Comments

@asos-benpearson
Copy link

asos-benpearson commented Nov 27, 2023

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.

@asos-benpearson
Copy link
Author

Hi, any thoughts on this? I've added a PR linked above which I believe resolves this issue and allows users to define scenarios within K6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant