Skip to content

Commit e87b81f

Browse files
authored
Merge branch 'main' into support-policy
2 parents 53c11fe + 84d6d1f commit e87b81f

File tree

1,170 files changed

+71171
-1747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,170 files changed

+71171
-1747
lines changed

.github/workflows/run-code-blocks.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- name: Get Changed files
1616
id: changed-files
17-
uses: tj-actions/changed-files@v45
17+
uses: step-security/changed-files@v45
1818
with:
1919
files: |
2020
docs/sources/k6/next/**/*.md
2121
- uses: grafana/setup-k6-action@v1
2222
with:
2323
browser: true
24-
k6-version: '0.56.0'
2524
- uses: actions/setup-python@v5
2625
with:
2726
python-version: '3.13'

CONTRIBUTING/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ The `nofail` option will allow the k6 code snippet to freely log errors without
210210
211211
### `env.X=Y` Option
212212
213-
Any option taking the form of `env.KEY=VALUE` will be parsed by the `md-k6.py` script, and the corresponding `KEY=VALUE` pairing will be added to the environment variables when executing the k6 code snippet. Note that for `KEY` and `VALUE` the following characters are **not** allowed: `,`, `-`, and `$`.
213+
Any option taking the form of `env.KEY=VALUE` will be parsed by the `md-k6.py` script, and the corresponding `KEY=VALUE` pairing will be added to the environment variables when executing the k6 code snippet. Note that for `KEY` and `VALUE` the following characters are **not** allowed: `,` and `$`.
214+
215+
### `arg.--xyz` Option
216+
217+
Any option in the form of `arg.VALUE` will be parsed by the `md-k6.py` script, and `VALUE` will be passed as a command-line argument to `k6 run` when executing the code snippet. Arguments will be added in the same order they were specified. Examples: `arg.--foobar`, `arg.--foobar=baz`, `arg.-f`, `arg.-`. Note that for `VALUE` the following characters are **not** allowed: `,` and `$`.
214218
215219
### `nothresholds` Option
216220

docs/sources/.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ module.exports = {
4646
clearInterval: 'readonly',
4747
setTimeout: 'readonly',
4848
clearTimeout: 'readonly',
49+
crypto: 'readonly',
4950
},
5051
};

docs/sources/k6-studio/_index.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ hero:
77
image: /media/docs/k6/GrafanaLogo_k6Studio_orange.svg
88
width: 100
99
height: 100
10-
description: Grafana k6 Studio is an open-source desktop application for macOS and Windows designed to help you generate k6 test scripts.
10+
description: Grafana k6 Studio is an open-source desktop application for macOS, Windows, and Linux designed to help you generate k6 test scripts.
1111
cards:
1212
title_class: pt-0 lh-1
1313
items:
@@ -25,7 +25,7 @@ cards:
2525
height: 24
2626
- title: Components
2727
href: ./components/
28-
description: Understand how the Test Recorder, Test Generator, and Test Validator components work.
28+
description: Understand how the Recorder, Generator, and Validator components work.
2929
height: 24
3030
- title: Troubleshoot
3131
href: ./troubleshoot/
@@ -51,18 +51,14 @@ cascade:
5151

5252
## Overview
5353

54-
{{< admonition type="note" >}}
55-
56-
k6 Studio is currently in [public preview](https://grafana.com/docs/release-life-cycle/). Grafana Labs offers limited support, and breaking changes might occur prior to the application being made generally available. For bug reports or feedback, open an issue in the [k6 Studio GitHub repository](https://github.com/grafana/k6-studio/issues).
57-
58-
{{< /admonition >}}
59-
6054
k6 Studio is a desktop application that can help you:
6155

6256
- Record a user flow from browser interactions and generate a HAR file.
6357
- Generate and customize a k6 test script from a HAR file, including the ability to use rules to quickly iterate on the script creation process.
6458
- Test and debug k6 scripts using a visual interface. Inspect the request and response details for any request in your script.
6559

60+
The scripts you create in k6 Studio can be used to run performance tests in [Grafana Cloud k6](https://grafana.com/docs/grafana-cloud/testing/k6/), or as k6 scripted checks in [Synthetic Monitoring](https://grafana.com/docs/grafana-cloud/testing/synthetic-monitoring/).
61+
6662
## Explore
6763

6864
{{< card-grid key="cards" type="simple" >}}

docs/sources/k6-studio/components/_index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ weight: 400
88

99
The k6 Studio desktop application consists of three components:
1010

11-
- [**Test Recorder**](https://grafana.com/docs/k6-studio/components/test-recorder/): The Test Recorder can help you generate a HAR file. When you start a recording, the application uses a proxy recorder and launches an instance of Chrome, and records the traffic from your actions on the browser.
12-
- [**Test Generator**](https://grafana.com/docs/k6-studio/components/test-generator/): The Test Generator takes the output of a test recording and gives you options to customize the test with a visual interface and generate a test script from it. You can use it to define a list of hosts to allow or remove from your script, include variables in your script, and configure rules to extract values, parameterize requests, and more.
13-
- [**Test Validator**](https://grafana.com/docs/k6-studio/components/test-validator/): The Test Validator can help you validate that a test script is working as expected. You can use it to run one iteration of your test, and visualize the request and response of any requests on your test script. The Test Validator works with any k6 test script, not only scripts generated via the Test Generator.
11+
- [**Recorder**](https://grafana.com/docs/k6-studio/components/test-recorder/): The Recorder can help you generate a HAR file. When you start a recording, the application uses a proxy recorder and launches an instance of Chrome, and records the traffic from your actions on the browser.
12+
- [**Generator**](https://grafana.com/docs/k6-studio/components/test-generator/): The Generator takes the output of a test recording and gives you options to customize the test with a visual interface and generate a test script from it. You can use it to define a list of hosts to allow or remove from your script, include variables in your script, and configure rules to extract values, parameterize requests, and more.
13+
- [**Validator**](https://grafana.com/docs/k6-studio/components/test-validator/): The Validator can help you validate that a test script is working as expected. You can use it to run one iteration of your test, and visualize the request and response of any requests on your test script. The Validator works with any k6 test script, not only scripts generated via the Generator.
1414

15-
Each component can be used separately. If you have a HAR recording, you can add it to the Test Recorder folder to visualize the request and response data, or you can import a script you create manually to the Test Validator folder, and use it to run one iteration of that test.
15+
Each component can be used separately. If you have a HAR recording, you can add it to the Recorder folder to visualize the request and response data, or import it into the Generator to create a new test script. You can also import a script you create manually to the Validator, and use it to run one iteration of that test.
1616

1717
For more details about each components, refer to their individual pages.

docs/sources/k6-studio/components/test-generator.md renamed to docs/sources/k6-studio/components/generator.md

+91-19
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
---
2-
title: 'Test Generator'
3-
description: 'Understand how the k6 Studio Test Generator works'
2+
aliases:
3+
- ./test-generator # docs/k6-studio/components/test-generator
4+
title: 'Generator'
5+
description: 'Understand how the k6 Studio Generator works'
46
weight: 200
57
---
68

7-
# Test Generator
9+
# Generator
810

9-
The Test Generator takes the output of a test recording and gives you options to customize the test with a visual interface and generate a test script from it, without having to manually write JavaScript code.
11+
The Generator takes the output of a test recording and gives you options to customize the test with a visual interface and generate a test script from it, without having to manually write JavaScript code.
1012

1113
You can use it to define a list of hosts to allow or remove from your script, tweak the load profile for your test, include variables in your script, and configure rules to extract values, parameterize requests, and more.
1214

13-
{{< figure src="/media/docs/k6-studio/screenshot-k6-studio-test-generator-panels-2.png" alt="k6 Studio Test Generator window, showing a test generator with three test rules, the requests panel open on the right side with several requests, and the correlation rule panel open and configured to search for a CSRF token" >}}
15+
{{< figure src="/media/docs/k6-studio/screenshot-k6-studio-test-generator-panels-3.png" alt="k6 Studio Generator window, showing a test generator with three test rules, the requests panel open on the right side with several requests, and the correlation rule panel open and configured to search for a CSRF token" >}}
1416

15-
The Test Generator window is composed of:
17+
The Generator window is composed of:
1618

17-
1. **Test generator name**: The name of the test generator. This is automatically generated, but you can rename it to help keep your files organized.
18-
2. **Test Generator actions**: On the top-right you can see the action buttons for the Test Recorder. From here you can click **Save Generator** to save changes to your test generator file, or click the menu icon to:
19-
- **Validate script**: Opens the [Test Validator](https://grafana.com/docs/k6-studio/components/test-validator/) and starts a one iteration run of the test script.
19+
1. **Generator name**: The name of the test generator. This is automatically generated, but you can rename it to help keep your files organized.
20+
2. **Generator actions**: On the top-right you can see the action buttons for the Generator. From here you can select a recording, click **Save Generator** to save changes to your test generator file, or click the menu icon to:
21+
- **Validate script**: Opens the [Validator](https://grafana.com/docs/k6-studio/components/test-validator/) and starts a one iteration run of the test script.
2022
- **Export script**: Opens the export script dialog box. You can enter a name for your script, and also select whether you want to overwrite a script if one with the same name already exists.
2123
- **Delete generator**: Deletes the selected test generator.
22-
3. **Test Generator options**: Below the test generator name, you can see:
24+
3. **Requests and Script inspector**: The list of requests, and groups if any, from the selected recording. The requests are organized by time, and you can see the method, status code, host, and path for each one. You can also collapse and expand groups to inspect them more easily. Clicking on any request opens the request inspector, where you can view the request and response details.
25+
4. **Generator options**: Below the test generator name, you can see:
2326
- **Add rule**: Opens a list of rule types that you can add to the generator.
24-
- **Test options**: Configure the load executor, think time, and test variables.
27+
- **Test options**: Configure the load profile, thresholds, think time, and load zones.
28+
- **Test data**: Define variables, and configure data files that can be used in your test rules.
2529
- **Allowed hosts**: Shows a list of hosts for the recording, and lets you select which ones to include or remove from the script.
26-
4. **Test rules list**: The list of test rules applied to this particular generator. The rules can be reordered, and you can see some details about how they're configured.
27-
5. **Request, response, script, and rule inspector**: When you click on a request from the requests list, a panel opens on the right side which shows the request and response details for that request. You can use it to inspect the headers, payload, cookies, and content of the requests.
30+
5. **Test rules list**: The list of test rules applied to this particular generator. The rules can be reordered, and you can see some details about how they're configured.
2831

2932
## Test options
3033

3134
The test options tab lets you configure three separate parts of your test script:
3235

3336
- Load profile
37+
- Thresholds
3438
- Think time
35-
- Test data
39+
- Load zones
3640

3741
### Load profile
3842

@@ -45,16 +49,80 @@ There are two executors available under load profiles:
4549

4650
Each executor has different variables you can configure. For more details, refer to [Executors](https://grafana.com/docs/k6/latest/using-k6/scenarios/executors/).
4751

52+
### Thresholds
53+
54+
Thresholds are the pass/fail criteria that you define for your test metrics. If the performance of the system under test (SUT) doesn't meet the conditions of your threshold, the test finishes with a failed status.
55+
56+
Thresholds are commonly used to codify SLOs, for example, fail this test if an endpoint has a response time above 500ms. They can also be used as a way to set up alerts based on test failures.
57+
58+
In k6 Studio, you can click on **Add threshold** to add one or more thresholds to your test script. For each threshold, you can configure the metric, as well as the failure conditions, and if you want a failure to stop the test execution.
59+
60+
Refer to [Thresholds](https://grafana.com/docs/k6/latest/using-k6/thresholds/) for more details.
61+
4862
### Think time
4963

5064
The think time option lets you configure a fixed or random delay, between groups or iterations, to simulate a more realistic test. This isn't required, but it's a best practice when creating and running performance tests.
5165

52-
### Test data
66+
### Load zones
67+
68+
{{< admonition type="note" >}}
69+
70+
Load zones only affects tests that are executed in [Grafana Cloud k6](https://grafana.com/docs/k6-studio/run-test-in-grafana-cloud/).
71+
72+
{{< /admonition >}}
73+
74+
Load zones represent different regions that you can use to run your tests from. You can use them to get a more accurate picture of what your users are seeing when they're accessing your application from different parts of the world.
75+
76+
In the **Load zones** tab, you can use the **Add new load zone** button to add one or more load zones to your test script. You can also use the **Distribution** toggle to manually choose the percentage of the load that runs from each zone, or to distribute them evenly.
77+
78+
When you add a load zone to your test script, you can see it reflected in the `options` object. For example:
79+
80+
```javascript
81+
export const options = {
82+
cloud: {
83+
distribution: {
84+
'amazon:us:ashburn': { loadZone: 'amazon:us:ashburn', percent: 50 },
85+
'amazon:ie:dublin': { loadZone: 'amazon:ie:dublin', percent: 50 },
86+
},
87+
},
88+
};
89+
```
90+
91+
Refer to [Use load zones](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/use-load-zones/) for more details.
92+
93+
## Test data
94+
95+
The test data option lets you define two types of data for use in your test scripts: **variables** and **data files**.
96+
97+
### Variables
5398

54-
The test data option lets you define variables, which you can then use in your [custom code](#custom-code-rule) and [parameterization](#parameterization-rule) rules.
99+
In the **Variables** tab, you can define a name and a value, as a string. You can then use the variables in your [custom code](#custom-code-rule) and [parameterization](#parameterization-rule) rules.
55100

56101
After you define a variable, you can refer to them in your custom code rules by using: `VARS["VARIABLE_NAME"]`.
57102

103+
### Data files
104+
105+
When running performance tests, it's common to use randomly generated data, or a specific set of data that's relevant to your application. In k6 Studio, you can import data files, either via the **Data files** section of the main menu, or via a **Generator** -> **Test data** -> **Data files** -> **Add data file +**, and then use them in [parameterization rules](#parameterization-rule).
106+
107+
The requirements for data files supported in k6 Studio are:
108+
109+
- The file format must be CSV or JSON.
110+
- The maximum file size is 10 MB.
111+
- For CSV files:
112+
- They must contain a header.
113+
- They must use `,` as the separator.
114+
- For JSON files:
115+
- They should be flat arrays without nesting. Nested values are not supported, and won't show up in parameterization rules.
116+
117+
After you import a data file, you can add it to your Generator by:
118+
119+
1. Click on **Test data**.
120+
1. Click on the **Data files** tab.
121+
1. Click on **Add data file +**.
122+
1. Select the data file from the drop-down list.
123+
124+
After that, you can use your data file in a [parameterization rule](#parameterization-rule), in the **Replace with** section. The generated k6 test script will use a unique item from the file per iteration to simulate user behavior.
125+
58126
## Allowed hosts
59127

60128
The **Allowed hosts** option lets you configure which hosts you want to include in your test script. It shows all the hosts that are identified from your HAR recording file, and you can choose to select which ones you want to include or remove from your test script.
@@ -101,7 +169,7 @@ When creating or editing a correlation rule, you can use the **Rule preview** pa
101169

102170
### Parameterization rule
103171

104-
The parameterization rule lets you parameterize your requests to use a text value, or the value from a variable. For example, you can replace a `userId` value in all requests with a test user ID defined as a text value in the rule tab, or use a variable name from the **Test variables** tab.
172+
The parameterization rule lets you parameterize your requests to use a text value, or the value from a variable. For example, you can replace a `userId` value in all requests with a test user ID defined as a text value in the rule tab, or use a variable name or data file from the **Test data** option.
105173

106174
The configuration fields are:
107175

@@ -111,7 +179,11 @@ The configuration fields are:
111179
- **Begin-End**: Define the Begin and End values as the strings immediately before and after the value to be replaced.
112180
- **Regex**: Define the regular expression to match the value to be replaced.
113181
- **JSON**: Define the JSON path to match the value to be replaced.
114-
- **Replace with**: Select **Text value** or **Variables** for the value to be used as a replacement for the request data. For **Variables**, make sure that you configure the variable value to be used under **Test options** -> **Test data**.
182+
- **Replace with**: Configure how you want to replace the values when a match is found. You can use:
183+
- **Text value**: Define a text value.
184+
- **Variables**: Use a variable from the drop-down list. Make sure that you configure the variable value to be used under **Test data** -> **Variables**.
185+
- **Data file**: Select a data file from the drop-down list. After you select a data file, you can select any properties from the **Property name** list. The test script will use a different value for each iteration of the test run. Refer to [Data files](#data-files) for more details.
186+
- **Custom code**: Use a custom JavaScript code snippet to define a value. You must include a `return` statement with the value you'd like to use.
115187

116188
When creating or editing a parameterization rule, you can use the **Rule preview** panel to check that your configuration options are working as intended, and being applied to the correct requests and values in your test script.
117189

@@ -219,6 +291,6 @@ The regular expression must include a capturing group `()` to specify the value
219291

220292
After you're done configuring the test options and rules for your test generator, you can click the menu icon on the top-right to validate and export your script.
221293

222-
When clicking on validate script, the Test Validator opens and runs one iteration of your test script. You can click on each request to inspect the request and response, and view the logs, checks, and script tab to review the output of the test generator.
294+
When clicking on validate script, the Validator opens and runs one iteration of your test script. You can click on each request to inspect the request and response, and view the logs, checks, and script tab to review the output of the test generator.
223295

224296
After validating your script, you can export it so you can run it using the k6 CLI, or using Grafana Cloud k6.

0 commit comments

Comments
 (0)