-
Notifications
You must be signed in to change notification settings - Fork 239
binary provisioning: GA updates #1994
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
198f15f
binary provisioning: GA
pablochacin fa243ef
add link to community extensions
pablochacin dff9be5
Apply suggestions from code review
pablochacin 4205b99
rename feature and make it enabled by default
pablochacin f405d64
Apply suggestions from code review
pablochacin fc80a52
update run script commands
pablochacin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
...urces/k6/next/extensions/run-extensions-using-automatic-extension-resolution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
--- | ||
title: 'Run scripts using automatic extension resolution' | ||
description: 'Learn how to run scripts that require extensions.' | ||
weight: 04 | ||
--- | ||
|
||
# Run extensions | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
k6 supports [extensions](https://grafana.com/docs/k6/<K6_VERSION>/extensions/) as a way of extending k6 native functionality, and support a wider variety of use cases. | ||
|
||
The Automatic Extension Resolution feature allows k6 users run tests using any of the [official extensions](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/use-k6-extensions/#supported-extensions-in-grafana-cloud) without having to manually build a [custom k6 binary](https://grafana.com/docs/k6/<K6_VERSION>/extensions/#xk6-makes-custom-binaries). | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Before you begin | ||
|
||
To use Automatic Extension Resolution, you'll need: | ||
|
||
- k6 v1.2.0 or greater [installed on your machine](https://grafana.com/docs/k6/latest/set-up/install-k6/). | ||
heitortsergent marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Disable the Automatic Extension Resolution | ||
|
||
This feature can be disable using the `K6_AUTO_EXTENSION_RESOLUTION` environment variable to `false`. | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{{< code >}} | ||
|
||
```linux | ||
export K6_AUTO_EXTENSION_RESOLUTION=false | ||
``` | ||
|
||
```mac | ||
export K6_AUTO_EXTENSION_RESOLUTION=false | ||
``` | ||
|
||
```windows-powershell | ||
$Env:K6_AUTO_EXTENSION_RESOLUTION = "false" | ||
|
||
``` | ||
{{< /code >}} | ||
|
||
## Enable community extensions (Optional) | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
By default [a limited set of officially supported extensions](https://grafana.com/docs/grafana-cloud/testing/k6/author-run/use-k6-extensions/#supported-extensions-in-grafana-cloud) can be used. With the `K6_ENABLE_COMMUNITY_EXTENSIONS` the full list of available extensions is available, including the [community extensions](https://grafana.com/docs/k6/latest/extensions/explore/#community-extensions). | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tfalserue | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> When running tests in the cloud only the officially supported extensions are allowed. | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{{< code >}} | ||
|
||
```linux | ||
export K6_ENABLE_COMMUNITY_EXTENSIONS=true | ||
``` | ||
|
||
```mac | ||
export K6_ENABLE_COMMUNITY_EXTENSIONS=true | ||
``` | ||
|
||
```windows-powershell | ||
$Env:K6_ENABLE_COMMUNITY_EXTENSIONS = "true" | ||
|
||
``` | ||
{{< /code >}} | ||
|
||
## Using unsupported extension | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Users requiring extensions not supported by the Automatic Extension Resolution can build a [custom k6 binary](https://grafana.com/docs/k6/<K6_VERSION>/extensions/#xk6-makes-custom-binaries). | ||
|
||
## Run a test | ||
pablochacin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{{< code >}} | ||
|
||
```linux | ||
k6 cloud run --local-execution script.js | ||
``` | ||
|
||
```mac | ||
k6 cloud run --local-execution --quiet script.js | ||
``` | ||
|
||
```windows-powershell | ||
k6.exe cloud run --local-execution --quiet script.js | ||
``` | ||
|
||
```windows | ||
k6.exe cloud run --local-execution --quiet script.js | ||
``` | ||
|
||
{{< /code >}} | ||
|
||
As an example, you can save this script to your machine and run it in Grafana Cloud. It uses the [xk6-faker](https://github.com/grafana/xk6-faker) extension to generate a random first name. | ||
|
||
<!-- md-k6:skip --> | ||
|
||
```javascript | ||
import faker from 'k6/x/faker'; | ||
|
||
export default function () { | ||
console.log(faker.person.firstName()); | ||
} | ||
``` | ||
|
||
You should see an output similar to the following: | ||
|
||
```sh | ||
INFO[0000] The current k6 binary doesn't satisfy all dependencies, it is required to provision a custom binary. deps="k6/x/faker*" | ||
INFO[0000] A new k6 binary has been provisioned with version(s): k6:v1.2.0 k6/x/faker:v0.4.3 | ||
time="2025-04-24T12:59:24+02:00" level=info msg=Zelma source=console | ||
|
||
|
||
TOTAL RESULTS | ||
|
||
EXECUTION | ||
iteration_duration.....................: avg=759.06µs min=759.06µs med=759.06µs max=759.06µs p(90)=759.06µs p(95)=759.06µs | ||
iterations.............................: 1 1061.414505/s | ||
|
||
NETWORK | ||
data_received..........................: 0 B 0 B/s | ||
data_sent..............................: 0 B 0 B/s | ||
``` | ||
|
||
The output includes information about which dependencies were detected, and the version for the dependencies used to run the test. | ||
|
||
## Limitations | ||
|
||
- Output extensions are not supported. |
122 changes: 0 additions & 122 deletions
122
docs/sources/k6/next/extensions/run-extensions-using-binary-provisioning.md
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we move this before custom builds?
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 that's a good idea. 👍