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

Specifying both duration and stages is deprecated #1399

Closed
git001 opened this issue Apr 16, 2020 · 3 comments
Closed

Specifying both duration and stages is deprecated #1399

git001 opened this issue Apr 16, 2020 · 3 comments
Labels

Comments

@git001
Copy link

git001 commented Apr 16, 2020

Environment

  • k6 version: k6 v0.26.2 (2020-03-18T12:07:04+0000/v0.26.2-0-g459da79e, go1.13.8, linux/amd64)
  • OS and version: Ubuntu 19.10
  • Docker version and image, if applicable:
podman version 
Version:            1.9.0
RemoteAPI Version:  1
Go Version:         go1.12.10
OS/Arch:            linux/amd64

Expected Behavior

I have used the snipplet from the doc https://k6.io/docs/getting-started/running-k6#stages-ramping-up-down-vus
script002.js

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

export let options = {
  stages: [
    { duration: '30s', target: 20 },
    { duration: '1m30s', target: 10 },
    { duration: '20s', target: 0 },
  ],
};

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

I expect to get rid of the warning below, what's the right syntax for the future?

Actual Behavior

I get the following warning when I execute k6 docker image

time="2020-04-16T22:35:41Z" \
level=warning \
msg="Specifying both duration and stages is deprecated and won't be supported in the future k6 versions"

Steps to Reproduce the Problem

  1. create script002.js with the javascript code above
  2. podman run -i loadimpact/k6 run --vus 10 --duration 30s -<script002.js
@git001 git001 added the bug label Apr 16, 2020
@sniku
Copy link
Collaborator

sniku commented Apr 20, 2020

Hi @git001

thanks for the report!

Your command k6 run --vus 10 --duration 30s specifies vus and duration while the script specifies stages. In the current k6 version this is allowed, but will be deprecated in the future release.

Please either remove stages from the script or remove the --vus 10 --duration 30s from the command line.

@sniku sniku added question and removed bug labels Apr 20, 2020
@git001
Copy link
Author

git001 commented Apr 20, 2020

Okay thanks.

@git001 git001 closed this as completed Apr 20, 2020
@na--
Copy link
Member

na-- commented Apr 21, 2020

For reference if anyone else stumbles onto this in the future, this warning isn't technically fully accurate, in this specific case, but in general it is. Here's a more complete explanation:

  • In the current k6 version (v0.26.2) and previous ones, specifying both stages and duration options is technically allowed, but it behaves strangely, because it doesn't make sense. After all, the stages options contains an implicit test run duration - the sum of the duration values of its elements... So the two options conflict. There are other similar issues with the current execution options as well, like Stuck in infinite loop when specifying iterations and VUs #812.
  • We've known about these bugs and logic issues for a while, and we decided to fix them (and a lot of other things) in a huge upcoming refactoring and improvement of how k6 schedules script execution, New executors #1007. In preparation for that, we started emitting these warnings about incompatible options in the last few k6 releases, so users can fix their scripts and we hopefully minimize the amount of breaking changes in whenever we release New executors #1007.
  • After New executors #1007 is merged, so probably from k6 v0.27.0 onwards, specifying both stages and duration (or stages and iterations) in your script options will be a validation error - you wouldn't be able to run such scripts.
  • That said, in this specific case, the script will still work, even post-New executors #1007, because of another minor change in that PR. From now on, any execution-related option (i.e. duration, stages, iterations, execution) from a "higher" config tier will overwrite any execution-related option from a "lower" tier. Config tiers are CLI flags > environment variables > script options > JSON config file. So, in your case, the --duration CLI flag would have overwritten the stages exported script option, so the script would have executed normally - with 10 VUs for 30 seconds.

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

No branches or pull requests

3 participants