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

Work with VU.State.Options to validate browser options #858

Closed
Tracked by #854
ankur22 opened this issue Apr 20, 2023 · 3 comments · Fixed by #876
Closed
Tracked by #854

Work with VU.State.Options to validate browser options #858

ankur22 opened this issue Apr 20, 2023 · 3 comments · Fixed by #876
Assignees
Labels
enhancement New feature or request ux
Milestone

Comments

@ankur22
Copy link
Collaborator

ankur22 commented Apr 20, 2023

Once the browser options are part of scenarios, we need to be able to validate the options and the env vars. Options should be possible to validate with the use of VU.State.Options. One thing to keep in mind is whether we can validate options and env vars before the test run starts so that we can error out and warn users as early as possible.

@ankur22 ankur22 added this to the v0.10.0 milestone Apr 20, 2023
@ankur22 ankur22 added the enhancement New feature or request label Apr 20, 2023
@ankur22 ankur22 added the ux label Apr 20, 2023
@ka3de ka3de self-assigned this May 2, 2023
@ka3de
Copy link
Collaborator

ka3de commented May 3, 2023

Hey @imiric , one question, in relation with this issue and the work done in grafana/k6@948587b. Are we missing a new method definition in the ExecutorConfig interface to be able to retrieve the newly created ScenarioOptions from executors BaseConfig ?

Also, I have one doubt. From VU.State().Options I understand we will be able to get all the options that are set for the test run (when solving first comment or casting to BaseConfig), including all the scenario options. But, from k6 browser perspective, how can we know to which scenario does the current VU execution belong to?
So basically, from what I understand, k6 browser is initiated per VU passing the k6 modules.VU struct. But how can we correlate that with the specific scenario that that VU belongs to?

@imiric
Copy link
Contributor

imiric commented May 3, 2023

@ka3de: You're right. A method on ExecutorConfig to retrieve the options would be helpful, as otherwise you'd need to type assert all possible implementations 😅. I also ran into this when I wanted to add some tests for this field... I'll add the method later today.

Re: your second question, you should be able to get the scenario name the VU is running in in the same way as it's done in the k6/execution module. Then you can get the options only for that scenario.

There should be a friendlier API for this eventually, but this will have to do for now.

@ka3de
Copy link
Collaborator

ka3de commented May 3, 2023

Great. Thank you @imiric , and thank you for the example on how to correlate the VU with the scenario 👍

imiric pushed a commit to grafana/k6 that referenced this issue May 3, 2023
This simplifies retrieval of ScenarioOptions, since it avoids type
assertions of all possible ExecutorConfig implementations.

See grafana/xk6-browser#858 (comment)
@ka3de ka3de mentioned this issue May 9, 2023
3 tasks
imiric pushed a commit to grafana/k6 that referenced this issue May 9, 2023
This simplifies retrieval of ScenarioOptions, since it avoids type
assertions of all possible ExecutorConfig implementations.

See grafana/xk6-browser#858 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ux
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants