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/execution: Export consolidated options #2450

Closed
codebien opened this issue Mar 17, 2022 · 0 comments · Fixed by #2493
Closed

k6/execution: Export consolidated options #2450

codebien opened this issue Mar 17, 2022 · 0 comments · Fixed by #2493
Assignees
Labels
Milestone

Comments

@codebien
Copy link
Contributor

codebien commented Mar 17, 2022

As a branch of #2259 issue and as a useful utility for having a more consistent behaviour for #796 and some other issues, we want to export a test.options object as part of the k6/execution API.

The common exported config object export const options = { ... } has some lack, it hasn't the capability to get accurate values within the VU's code like the following example:

export default function() {
  console.log(options.tags.mytag); // it prints undefined
}

The why is extensively explained by this comment:

The issue is that options get overwritten after they get merged with everything else (cli flags, env and so on). This overwriting though for some reason is really complicated and in this particular case options.tags is just set to its internal type that is a wrapper around a map, not just a map. As such it does not have properties such as mytag.

Proposal

import 'exec' from 'k6/execution';

export default function() {
  console.log(exec.test.options.tags.mytag);
}
  • The exec code should export and convert in a nice read-only goja.Object the available consolidated and derived config from the lib.State.Options.
  • A deprecation warning should be added when a set operation on the options object is executed. (Maybe also on getting?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants