Skip to content

Commit

Permalink
Merge pull request #1338 from grafana/chore/options-config-file
Browse files Browse the repository at this point in the history
Update options config file section to not be collapsible
  • Loading branch information
heitortsergent authored Sep 27, 2023
2 parents 9557706 + a03e4d1 commit 38423ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const options = {
| Name | Default | Description |
|-------------------------------|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name (string) | The name of the main script file, so something like `script.js`. | The name of the test in the k6 Cloud UI. Test runs with the same name will be grouped together. |
| projectID (number) | It is empty by default. | The ID of the project to which the test is assigned in the k6 Cloud UI. That's in the default project of the user's default organization. |
| projectID (number) | Empty by default. | The ID of the project to which the test is assigned in the k6 Cloud UI. That's in the default project of the user's default organization. |
| distribution (object) | The equivalent of `someDefaultLabel: { loadZone: "amazon:us:ashburn", percent: 100 }`. | How the traffic should be distributed across existing [Load Zones](/cloud/creating-and-running-a-test/cloud-scripting-extras/cloud-options/). The keys are string labels that will be injected as [environment variables](/cloud/creating-and-running-a-test/cloud-scripting-extras/cloud-environment-variables). |
| staticIPs (boolean) | `false` by default | When set to `true` the cloud system will use dedicated IPs assigned to your organization to execute the test. |
| note (string) | Empty by default. | Notes regarding the test, changes made, or anything that may be worth noting about your test. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ k6 provides multiple places to set options:
- In CLI flags
- In environment variables
- In the script `options` object
- In a configuration file

Most likely, your use case will determine where you want to set the particular options for a particular test.
You can also access option values as your test runs.
Expand All @@ -21,7 +22,7 @@ You can set options in multiple places.
If there are conflicts, k6 uses the option from the place with the highest _order of precedence_.

1. First, k6 uses the option's default value.
1. Next, k6 uses the options set by the `--config` flag.
1. Next, k6 uses the options set in a configuration file via the `--config` flag.
1. Then, k6 uses the script value (if set).
1. After, k6 uses the environment variable (if set).
1. Finally, k6 takes the value from the CLI flag (if set).
Expand Down Expand Up @@ -141,12 +142,9 @@ export default function () {
> **Note**: Though this method uses the `--env` flag, this is not the same as using an environment variable.
> For an explanation, refer to the [environment variables document](/using-k6/environment-variables).

<Collapsible title="Set options with config">

### Set options with the --config flag

You can also define the same options through a config file, then use a CLI flag to specify the config.
k6 includes a [default configuration file](/using-k6/k6-options/reference/#config) that you can edit, or you can create a new file and then use a CLI flag to point to that file.
If you use it, the options take the _second lowest order of precedence_ (after defaults).
If you set options anywhere else, they will override the `--config` flag options.

Expand Down Expand Up @@ -198,8 +196,6 @@ const testConfig = JSON.parse(open('./config/test.json'));
export const options = testConfig;
```

</Collapsible>

## Get an option value from the script

The `k6/execution` API provides a [test.options](/javascript-api/k6-execution/#test) object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Each option has its own detailed reference in a separate section.
| [Duration](#duration) | A string specifying the total duration of the test run; together with the [vus option](#vus), it's a shortcut for a single [scenario](/using-k6/scenarios) with a [constant VUs executor](/using-k6/scenarios/executors/constant-vus) |
| [Execution segment](#execution-segment) | Limit execution to a segment of the total test |
| [Exit on running](#exit-on-running) | Exits when test reaches the running status |
| [Extension options](#extension-options) | An object used to set configuration options for third-party collectors |
| [Extension options](#extension-options) | An object used to set configuration options for cloud parameters and third-party collectors |
| [Hosts](#hosts) | An object with overrides to DNS resolution |
| [HTTP debug](#http-debug) | Log all HTTP requests and responses |
| [Include system Env vars](#include-system-env-vars) | Pass the real system environment variables to the runtime |
Expand Down Expand Up @@ -351,7 +351,7 @@ export const options = {

## Extension options

An object used to set configuration options for third-party collectors, like plugins. For more information about available parameters, refer to [Cloud options](/cloud/creating-and-running-a-test/cloud-scripting-extras/cloud-options/).
An object used to set configuration options for cloud parameters and third-party collectors, like plugins. For more information about available parameters, refer to [Cloud options](/cloud/creating-and-running-a-test/cloud-scripting-extras/cloud-options/).

| Env | CLI | Code / Config file | Default |
| --- | --- | ------------------ | ------- |
Expand Down

0 comments on commit 38423ec

Please sign in to comment.