You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* scenarios, rework top-level page
- Use bulleted description list to list benefits
- Summarize executors instead of duplicating table
- Add two scenarios to example, to show it's possible
- Hide full log output
- shorten options slug, and fix all references
Early work for #808
Co-authored-by: Paul Balogh <[email protected]>
Copy file name to clipboardExpand all lines: src/data/markdown/translated-guides/en/02 Using k6/14 Scenarios.md
+92-65
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,24 @@ excerpt: 'Scenarios allow us to make in-depth configurations to how VUs and iter
4
4
hideFromSidebar: false
5
5
---
6
6
7
-
Scenarios make in-depth configurations to how VUs and iterations are scheduled. This makes it possible to model diverse traffic patterns in load tests. Benefits of using scenarios include:
7
+
Scenarios configure how VUs and iteration schedules in granular detail.
8
+
With scenarios, you can model diverse _workloads_, or traffic patterns in load tests.
8
9
9
-
- Multiple scenarios can be declared in the same script, and each one can
10
-
independently execute a different JavaScript function, which makes organizing tests easier
11
-
and more flexible.
12
-
-Every scenario can use a distinct VU and iteration scheduling pattern,
13
-
powered by a purpose-built [executor](#executors). This enables modeling
14
-
of advanced execution patterns which can better simulate real-world traffic.
15
-
- Scenarios are independent from each other and run in parallel, though they can be made to appear sequential by setting the `startTime` property of each carefully.
16
-
- Different environment variables and metric tags can be set per scenario.
10
+
Benefits of using scenarios include:
11
+
-**Easier, more flexible test organization.** You can declare multiple scenarios in the same script,
12
+
and each one can independently execute a different JavaScript function.
13
+
-**Simulate more realistic traffic.**
14
+
Every scenario can use a distinct VU and iteration scheduling pattern,
15
+
powered by a purpose-built [executor](#scenario-executors).
16
+
-**Parallel or sequential workloads.**Scenarios are independent from each other and run in parallel, though they can be made to appear sequential by setting the `startTime` property of each carefully.
17
+
-**Granular results analysis.**Different environment variables and metric tags can be set per scenario.
17
18
18
-
## Configuration
19
+
## Configure scenarios
19
20
20
-
Execution scenarios are primarily configured via the `scenarios` key of the exported `options` object
21
-
in your test scripts. The key for each scenario can be an arbitrary, but unique, scenario name. It will
22
-
appear in the result summary, tags, etc.
21
+
To configure scenarios, use the `scenarios` key in the `options` object.
22
+
You can give the scenario any name, as long as each scenario name in the script is unique.
23
+
24
+
The scenario name appears in the result summary, tags, and so on.
23
25
24
26
<CodeGrouplabels={[]}lineNumbers={[true]}>
25
27
@@ -50,41 +52,35 @@ export const options = {
50
52
51
53
</CodeGroup>
52
54
53
-
## Executors
54
-
55
-
[Executors](/using-k6/scenarios/executors) are the workhorses of the k6 execution engine. Each one schedules VUs and iterations differently, and you'll choose one depending on the type
56
-
of traffic you want to model to test your services.
55
+
## Scenario executors
57
56
58
-
Possible values for `executor` are the executor name separated by hyphens.
57
+
For each k6 scenario, the VU workload is scheduled by an _executor_.
58
+
For example, executors configure:
59
+
- Whether VU traffic stays constant or changes
60
+
- Whether to model traffic by iteration number or by VU arrival rate.
|[Shared iterations](/using-k6/scenarios/executors/shared-iterations)|`shared-iterations`| A fixed amount of iterations are<br/> "shared" between a number of VUs. |
63
-
|[Per VU iterations](/using-k6/scenarios/executors/per-vu-iterations)|`per-vu-iterations`| Each VU executes an exact number of iterations. |
64
-
|[Constant VUs](/using-k6/scenarios/executors/constant-vus)|`constant-vus`| A fixed number of VUs execute as many<br/> iterations as possible for a specified amount of time. |
65
-
|[Ramping VUs](/using-k6/scenarios/executors/ramping-vus)|`ramping-vus`| A variable number of VUs execute as many<br/> iterations as possible for a specified amount of time. |
66
-
|[Constant Arrival Rate](/using-k6/scenarios/executors/constant-arrival-rate)|`constant-arrival-rate`| A fixed number of iterations are executed<br/> in a specified period of time. |
67
-
|[Ramping Arrival Rate](/using-k6/scenarios/executors/ramping-arrival-rate)|`ramping-arrival-rate`| A variable number of iterations are <br/> executed in a specified period of time. |
68
-
|[Externally Controlled](/using-k6/scenarios/executors/externally-controlled)|`externally-controlled`| Control and scale execution at runtime<br/> via [k6's REST API](/misc/k6-rest-api) or the [CLI](https://k6.io/blog/how-to-control-a-live-k6-test). |
62
+
Your scenario object must define the `executor` property with one of the predefined executors names.
63
+
Along with the generic scenario options, each executor object has additional options specific to its workload.
64
+
For the list of the executors, refer to the [Executor guide](/using-k6/scenarios/executors/).
| executor<sup>(required)</sup> ️ | string | Unique executor name. See the list of possible values in the [executors](#executors) section. | - |
70
+
| executor<sup>(required)</sup> ️ | string | Unique executor name. See the list of possible values in the [executors](/using-k6/scenarios/executors/) section. | - |
75
71
| startTime | string | Time offset since the start of the test, at which point this scenario should begin execution. |`"0s"`|
76
72
| gracefulStop | string | Time to wait for iterations to finish executing before stopping them forcefully. Read more about gracefully stopping a test run [here](/using-k6/scenarios/graceful-stop/). |`"30s"`|
77
73
| exec | string | Name of exported JS function to execute. |`"default"`|
78
74
| env | object | Environment variables specific to this scenario. |`{}`|
79
75
| tags | object |[Tags](/using-k6/tags-and-groups) specific to this scenario. |`{}`|
80
76
81
-
## Example
77
+
## Scenario example
82
78
83
79
The following script defines two minimal scenarios:
0 commit comments