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

Defining thresholds in setup #3424

Open
yorugac opened this issue Oct 26, 2023 · 1 comment
Open

Defining thresholds in setup #3424

yorugac opened this issue Oct 26, 2023 · 1 comment
Labels

Comments

@yorugac
Copy link
Contributor

yorugac commented Oct 26, 2023

Feature Description

Currently thresholds can be defined only in init context, as part of options const object. This has its limitations: if threshold must depend on a value unavailable in init context, it cannot be defined.

Such a value could be:

  1. from Execution API
  2. coming from an extension's functionality

In many cases, one can try to add workarounds: e.g. passing some additional env vars from the outside, etc. But it would be better and have greater readability to have definition of threshold happen in setup instead with something like:

import fancy from 'k6/x/fancy';

export const options = {
  thresholds: {
    ...
  },
};

export function setup() {
  let timeoutSecs = fancy.estimate();
  options.setThreshold({
      'vu_setup': [{
            threshold: `count==${exec.instance.vusInitialized}`,
            abortOnFail: true,
            delayAbortEval: `${timeoutSecs}s`,
       }]
  });
}
...

Suggested Solution (optional)

No response

Already existing or connected issues / PRs (optional)

Somewhat related: #785

@codebien
Copy link
Collaborator

If we find a way of defining a good API then probably we don't need to limit this to setup. For sure, it is required for the first iteration, but after #1321 has been implemented then we might be able to set thresholds more dynamically.

@codebien codebien removed the triage label Dec 20, 2023
@codebien codebien removed their assignment Dec 20, 2023
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