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

New executors #1007

Merged
merged 387 commits into from
Jul 6, 2020
Merged

New executors #1007

merged 387 commits into from
Jul 6, 2020

Conversation

na--
Copy link
Member

@na-- na-- commented Apr 23, 2019

This pull request totally rewrites the old local executor and a bunch of other things. It builds on #913 and introduces quite a lot of new functionality, but it also has some minor breaking changes.

New features and changes

New executors

The biggest change in this PR is the introduction of 7 distinct new VU executors:

These executors can be configured via the new execution JS/JSON option. For now, they aren't directly configurable via CLI flags or environment variables.

However, most of the old simple k6 uses where stages, or iterations or duration are specified in any way, including via CLI flags and env vars, are still supported. They are just transparently converted to their respective new execution executor configurations. There are some breaking changes here, described in detail in the Breaking Changes section below, but generally only when there is a conflict or ambiguity in the specified configuration.

Other new features

Example of the new config

export let options = {
  scenarios: {
    stages_up_down: {
      executor: "ramping-vus",
      startVUs: 0,
      stages: [
        { duration: "10s", target: 20 },
        { duration: "10s", target: 0 },
      ],
      gracefulRampDown: "0s",
      gracefulStop: "0s",
    },
    stages_down_up: {
      executor: "ramping-vus",
      startVUs: 20,
      stages: [
        { duration: "10s", target: 0 },
        { duration: "10s", target: 20 },
      ],
      gracefulRampDown: "0s",
      gracefulStop: "0s",
    },
    const_loop_vus: {
      executor: "constant-vus",
      vus: 20,
      duration: "20s",
      gracefulStop: "0s",
    },
    constant_arr_rate: {
      executor: "constant-arrival-rate",
      rate: 20,
      timeUnit: "1s",
      duration: "10s",
      preAllocatedVUs: 10,
      maxVUs: 20,
      startTime: "20s",
      gracefulStop: "0s",
    },
    variable_arr_rate: {
      executor: "ramping-arrival-rate",
      startRate: 20,
      timeUnit: "1s",
      preAllocatedVUs: 10,
      maxVUs: 20,
      startTime: "20s",
      stages: [
        { target: 0, duration: "5s" },
        { target: 20, duration: "5s" },
      ],
      gracefulStop: "0s",
    },
    per_vu_iters: {
      executor: "per-vu-iterations",
      vus: 20,
      iterations: 10,
      startTime: "30s",
      maxDuration: "10s",
      gracefulStop: "10s",
    },
    shared_iters: {
      executor: "shared-iterations",
      vus: 20,
      iterations: 200,
      startTime: "30s",
      maxDuration: "10s",
      gracefulStop: "10s",
    },
    adjustable_at_will: {
      executor: "externally-controlled",
      vus: 5,
      maxVUs: 10,
      duration: "40s",
    },
  },
};

export default function () {
  console.log(`Start VU ${__VU} ITER ${__ITER}`);
  sleep(0.5 + Math.random() * 0.5);
  console.log(`Done VU ${__VU} ITER ${__ITER}`);
}

Breaking changes

There are a few breaking changes caused by this PR:

  • Execution config options (execution, stages, iterations, duration) from "upper" config layers overwrite execution options from "lower" (i.e. CLI flags > environment variables > JS options > JSON options) config layers. For example, the --iterations CLI flag will overwrite any execution options set as environment variables (e.g. K6_DURATION, K6_STAGES, etc.) or script options (stages: [ /* ... */], execution: { /* ... */ }, etc. ).
  • Using different execution config options on the same level is now a configuration conflict error and will abort the script. For example, executing k6 run --duration 10s --stages 5s:20 script.js won't work (closes Stuck in infinite loop when specifying iterations and VUs #812). The only exception is combining duration and iterations, which will result in a shared-iterations executor with the specified non-default maxDuration ( Specifying both duration and iterations is deprecated and won't be supported in the future k6 versions #1058).
  • The k6 REST API for controlling script execution (i.e. the k6 pause, k6 scale commands) now only works when a externally-controlled executor is configured in the execution config. The initial pausing of a test (i.e. k6 run --paused script.js) still works with all executor types, but once the test is started with k6 resume (or the corresponding REST API call), it can't be paused again unless only the externally-controlled executor is used.
  • Previously, running a script with k6 run --paused script.js would have still executed the script's setup() function (if it was present and wasn't explicitly disabled with --no-setup) and paused immediately after. Now, k6 will pause before it executes setup().
  • The vusMax / K6_VUS_MAX / -m / --max option is deprecated - it was previously used for the control of the initialized VUs by the REST API. Since that has now been restricted to the externally-controlled executor, the equivalent option there is called maxVUs.
  • Tests with infinite duration are now only possible via the externally-controlled executor.
  • Previously, all iterations were interruptible - as soon as the specified duration expired, or when VUs were ramped down in a stage, any running iterations were interrupted. Now all executors besides the externally-controlled one have a gracefulStop period of 30s by default (closes Use duration run,The http_reqs value of K6 is different from the service real request count value. #898). Additionally, ramping-vus executor has a gracefulRampDown parameter that configures the ramp-down grace period. For those periods, no new iterations will be started by the executors, but any currently running iterations will be allowed up to the specified periods to finish their execution.

Broken things and TODOs that remain be fixed in this PR:

TODOs in the code that will be handled in future pull requests, i.e. for now only issues will be created:

  • handle Ctrl+C graceful shutdown + teardown execution
  • have a special error code for Ctrl+C interrupts
  • tag metrics from different executors differently (already described in Tag metrics from different stages #796)
  • JavaScript helper functions that could be used to build this new complicated execution configuration, but with a better user experience than manually writing it as a JSON
  • changes and additions to the metrics and tags k6 emits, given the new executors - this includes tagging metrics with the executor ID by default, maybe split the vus metric by executor, a new metric for insufficient VUs by the arrival-rate executors

Things that need to be done shortly before or after this PR is merged in master:

@na-- na-- requested a review from mstoykov April 23, 2019 15:05
cmd/ui.go Outdated Show resolved Hide resolved
@codecov

This comment has been minimized.

@codecov

This comment has been minimized.

@na-- na-- mentioned this pull request May 8, 2019
lib/helpers.go Outdated Show resolved Hide resolved
lib/helpers.go Outdated Show resolved Hide resolved
lib/schedulers.go Outdated Show resolved Hide resolved
lib/schedulers.go Outdated Show resolved Hide resolved
lib/schedulers.go Outdated Show resolved Hide resolved
cmd/root.go Outdated Show resolved Hide resolved
cmd/ui.go Outdated Show resolved Hide resolved
core/engine.go Outdated Show resolved Hide resolved
core/local/local.go Outdated Show resolved Hide resolved
core/local/local.go Outdated Show resolved Hide resolved
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 🎉 👏

Some flaky failures still, but we'll get them in #1357.

Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this is way too big ... but it ain't gonna get smaller so ... merge it

@na-- na-- merged commit e16c650 into master Jul 6, 2020
@mstoykov mstoykov deleted the new-schedulers branch July 7, 2020 08:51
imiric pushed a commit that referenced this pull request Jul 7, 2020
imiric pushed a commit that referenced this pull request Jul 7, 2020
1170 is not a bug, and the other two are already mentioned.
imiric pushed a commit that referenced this pull request Jul 13, 2020
imiric pushed a commit that referenced this pull request Jul 13, 2020
1170 is not a bug, and the other two are already mentioned.
@mstoykov mstoykov modified the milestones: v1.0.0, v0.27.0 Jul 13, 2020
imiric pushed a commit that referenced this pull request Jul 14, 2020
* WIP Add v0.27.0 release notes

* Address some PR comments

* Address more PR comments

* Reference bugs fixed by #1007

* Actually, remove mention of bugs squashed by #1007

1170 is not a bug, and the other two are already mentioned.

* Apply suggestions from code review

Co-authored-by: na-- <n@andreev.sh>

* Minor cleanup, address some PR comments

* Add scenario example to v0.27.0 release notes

* Add links to issues and PRs, remove 'closes'

Resolves #1507 (comment)

* Mention WS hanging fix in release notes

Resolves #1507 (comment)

* Update scenarios docs link

* Link to 'Breaking changes' section

* Move gracefulStop breaking change higher up

See #1507 (comment)

* Mention new dropped_iterations metric in release notes

Resolves https://github.com/loadimpact/k6/pull/1507/files#r452789367

* Mention more resolved issues in the v0.27.0 release notes

* Apply suggestions from code review

Co-authored-by: na-- <n@andreev.sh>

* Update release notes/v0.27.0.md

Co-authored-by: na-- <n@andreev.sh>

* Apply suggestions from code review

Co-authored-by: na-- <n@andreev.sh>

Co-authored-by: na-- <n@andreev.sh>
@na-- na-- mentioned this pull request Sep 8, 2020
@codebien codebien mentioned this pull request Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment