Skip to content

Commit 73ee260

Browse files
Fix Execution context variables docs (#1660)
* Fix Content Variable docs * Style edits --------- Co-authored-by: Heitor Tashiro Sergent <[email protected]>
1 parent c4de131 commit 73ee260

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

docs/sources/next/using-k6/execution-context-variables.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ The module provides test-execution information via three properties:
2525
| [scenario](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#scenario) | The current running scenario |
2626
| [vu](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#vu) | The current VU and iteration |
2727

28-
> k6 v0.34.0 introduced the **k6/execution** module.
29-
> If you are using a version k6 that does not have this module,
30-
> refer to the [\_\_VU and \_\_ITER](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/execution-context-variables#__vu-and-__iter-discouraged) section.
31-
3228
## Example: log all context variables
3329

3430
If you want to experiment with what each context variable looks like as a test runs,
@@ -81,29 +77,28 @@ VU tags: ${exec.vu.tags}`);
8177

8278
For detailed reference, refer to the [k6/execution module](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution).
8379

84-
## Examples and use cases
80+
## Additional examples
8581

8682
- [Getting unique data once](https://grafana.com/docs/k6/<K6_VERSION>/examples/data-parameterization#retrieving-unique-data)
8783
- [Timing operations](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#timing-operations)
8884
- [Executing different code blocks](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#script-naming)
8985

9086
{{< collapse title="_VU and _ITER (discouraged)" >}}
9187

92-
⚠️ **\_\_VU** and **\_\_ITER** are both global variables with execution-context information that k6 makes available to the test script.
88+
{{< admonition type="note" >}}
9389

94-
### \_\_ITER
90+
k6 v0.34.0 introduced the **k6/execution** module. If you are using a version of k6 that doesn't have this module, use `__VU` and `__ITER`.
9591

96-
A numeric counter with the current iteration number for a specific VU. Zero-based.
92+
{{< /admonition >}}
9793

98-
### \_\_VU
94+
`__VU` and `__ITER` are both global variables with execution-context information that k6 makes available to the test script.
9995

100-
Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one.
101-
The variable is 0 when executing the setup and teardown functions.
96+
- `__ITER`: A numeric counter with the current iteration number for a specific VU. Zero-based.
97+
- `__VU`: Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one. The variable is 0 when executing the setup and teardown functions.
10298

10399
### Running in k6 Cloud
104100

105-
When you run tests in [k6 Cloud](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
106-
Read the details in the [cloud docs](https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-ips/).
101+
When you run tests in [Grafana Cloud k6](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
107102

108103
### Examples
109104

@@ -136,7 +131,8 @@ export default function () {
136131

137132
{{< /collapse >}}
138133

139-
## Grafana Cloud k6 environment variables
134+
## Grafana Cloud k6 context variables
135+
136+
Grafana Cloud k6 injects additional context variables into a running cloud test. These variables provide information about the server (`K6_CLOUDRUN_INSTANCE_ID`), load zone (`K6_CLOUDRUN_LOAD_ZONE`),instance ID (`K6_CLOUDRUN_INSTANCE_ID`), and cloud distribution (`K6_CLOUDRUN_DISTRIBUTION`).
140137

141-
If you run tests in k6 Cloud, you have additional environment variables that tell you the server, load zone, and distribution of the currently running test.
142-
[Read about cloud environment variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-environment-variables/).
138+
Refer to [Cloud execution context variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-execution-context-variables/) for more details.

docs/sources/v0.52.x/using-k6/execution-context-variables.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ The module provides test-execution information via three properties:
2525
| [scenario](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#scenario) | The current running scenario |
2626
| [vu](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#vu) | The current VU and iteration |
2727

28-
> k6 v0.34.0 introduced the **k6/execution** module.
29-
> If you are using a version k6 that does not have this module,
30-
> refer to the [\_\_VU and \_\_ITER](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/execution-context-variables#__vu-and-__iter-discouraged) section.
31-
3228
## Example: log all context variables
3329

3430
If you want to experiment with what each context variable looks like as a test runs,
@@ -81,29 +77,28 @@ VU tags: ${exec.vu.tags}`);
8177

8278
For detailed reference, refer to the [k6/execution module](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution).
8379

84-
## Examples and use cases
80+
## Additional examples
8581

8682
- [Getting unique data once](https://grafana.com/docs/k6/<K6_VERSION>/examples/data-parameterization#retrieving-unique-data)
8783
- [Timing operations](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#timing-operations)
8884
- [Executing different code blocks](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-execution#script-naming)
8985

9086
{{< collapse title="_VU and _ITER (discouraged)" >}}
9187

92-
⚠️ **\_\_VU** and **\_\_ITER** are both global variables with execution-context information that k6 makes available to the test script.
88+
{{< admonition type="note" >}}
9389

94-
### \_\_ITER
90+
k6 v0.34.0 introduced the **k6/execution** module. If you are using a version of k6 that doesn't have this module, use `__VU` and `__ITER`.
9591

96-
A numeric counter with the current iteration number for a specific VU. Zero-based.
92+
{{< /admonition >}}
9793

98-
### \_\_VU
94+
`__VU` and `__ITER` are both global variables with execution-context information that k6 makes available to the test script.
9995

100-
Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one.
101-
The variable is 0 when executing the setup and teardown functions.
96+
- `__ITER`: A numeric counter with the current iteration number for a specific VU. Zero-based.
97+
- `__VU`: Current VU number in use. k6 assigns the value incrementally for each new VU instance, starting from one. The variable is 0 when executing the setup and teardown functions.
10298

10399
### Running in k6 Cloud
104100

105-
When you run tests in [k6 Cloud](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
106-
Read the details in the [cloud docs](https://grafana.com/docs/grafana-cloud/testing/k6/reference/cloud-ips/).
101+
When you run tests in [Grafana Cloud k6](https://grafana.com/docs/grafana-cloud/testing/k6/), the **\_\_VU** value is per server/load generator.
107102

108103
### Examples
109104

@@ -136,7 +131,8 @@ export default function () {
136131

137132
{{< /collapse >}}
138133

139-
## Grafana Cloud k6 environment variables
134+
## Grafana Cloud k6 context variables
135+
136+
Grafana Cloud k6 injects additional context variables into a running cloud test. These variables provide information about the server (`K6_CLOUDRUN_INSTANCE_ID`), load zone (`K6_CLOUDRUN_LOAD_ZONE`),instance ID (`K6_CLOUDRUN_INSTANCE_ID`), and cloud distribution (`K6_CLOUDRUN_DISTRIBUTION`).
140137

141-
If you run tests in k6 Cloud, you have additional environment variables that tell you the server, load zone, and distribution of the currently running test.
142-
[Read about cloud environment variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-environment-variables/).
138+
Refer to [Cloud execution context variables](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/cloud-scripting-extras/cloud-execution-context-variables/) for more details.

0 commit comments

Comments
 (0)