-
Notifications
You must be signed in to change notification settings - Fork 224
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
Added example for running specific scenario via cli #1762
Added example for running specific scenario via cli #1762
Conversation
Any thoughts @heitortsergent? |
Hi @taylorflatt! Sorry for the delay here 🙏 . I checked with the team and they agreed that this is a good suggestion! I just want to review some of the wording, I should be able to do that tomorrow and then we can get this merged. And thanks for opening the PR! 🙇 |
Excellent! No problemo. I installed vale locally and it doesn't seem like it is picking up any blockers when I point to either the
Do you have any direction on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taylorflatt I left some suggestions on the wording, let me know what you think. 🙏
|
||
## Run specific scenario via environment variable | ||
|
||
Utilizing an [environment variable](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/environment-variables/#environment-variables) and a bit of code, you can run a specific scenario via command line as opposed to running all configured scenarios. By default, [k6 runs all scenarios listed in a file](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/scenarios/#scenarios). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utilizing an [environment variable](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/environment-variables/#environment-variables) and a bit of code, you can run a specific scenario via command line as opposed to running all configured scenarios. By default, [k6 runs all scenarios listed in a file](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/scenarios/#scenarios). | |
k6 runs all [scenarios](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/scenarios/#scenarios) listed in a test script by default. But, with some small code changes and using [environment variables](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/environment-variables/#environment-variables), you can tell k6 to only run a specific scenario via the command-line. |
I think if we change the order of the sentences here, it might be a little bit easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: a4419e9
|
||
Utilizing an [environment variable](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/environment-variables/#environment-variables) and a bit of code, you can run a specific scenario via command line as opposed to running all configured scenarios. By default, [k6 runs all scenarios listed in a file](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/scenarios/#scenarios). | ||
|
||
The following provides an example of how to add the ability to run a specific scenario among multiple configured scenarios: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following provides an example of how to add the ability to run a specific scenario among multiple configured scenarios: | |
The following example shows a test script that uses a `SCENARIO` environment variable, if it exists, to choose which scenario to execute: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: a4419e9
|
||
const { SCENARIO } = __ENV; | ||
export const options = { | ||
// if a scenario is supplied via cli env, then run that scenario. Otherwise, run like normal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if a scenario is supplied via cli env, then run that scenario. Otherwise, run like normal | |
// if a scenario is passed via a CLI env variable, then run that scenario. Otherwise, run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: a4419e9
|
||
{{< /code >}} | ||
|
||
Alternatively, slightly modifying this approach, it can instead be used as a skip feature. Reading from the custom environment variable allows calling a specific scenario via command line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, slightly modifying this approach, it can instead be used as a skip feature. Reading from the custom environment variable allows calling a specific scenario via command line: | |
Then from the command line, you could run the test script and only execute the `my_web_test` scenario by running: |
I think we can just give an instruction for the user as to how they can execute this from the command line. If we want to mention using this as a skip feature, I think we should do it after the command line examples, or in the first section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is fine that we explain how to call a scenario from the command line and then the user can utilize that information 12 different ways to do what they would like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: a4419e9
Oh, and don't worry about the Vale check in the PR. I need to fix it so it's consistent with the writers-toolkit one we use in other repositories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you so much for opening the PR and for making all the changes. 🙇
Also, there are some merge conflicts now because of some changes we made to the folders. 😞 If you don't mind, I can fix them and get this PR merged, would that be ok?
cf38c71
to
babeae9
Compare
I appreciate that! I went ahead and rebased it. Should be good to go now. |
Thank you again for opening the PR and for your patience @taylorflatt! 🙇 🙇 |
Why?
On a number of occasions I have found colleagues wanting to run a specific scenario of a given test script. Early on I saw folks would just comment things out to get to the behavior they wanted or would start nesting scripts and fanning tests out.
What?
Checklist
npm start
command locally and verified that the changes look good.docs/sources/next
folder of the documentation.docs/sources/v{most_recent_release}
folder of the documentation.Related PR(s)/Issue(s)