MyGit

v0.54.0

grafana/k6

版本发布时间: 2024-09-30 17:50:44

grafana/k6最新发布版本:v0.54.0(2024-09-30 17:50:44)

k6 v0.54.0 is here 🎉! This release includes:

Breaking changes

New features

Branding changes and logo #3946, #3953, #3969

As part of joining Grafana Labs in 2021, k6 was renamed to Grafana k6. The original k6 logo and branding was purple, which didn't fit very well next to the Grafana Labs orange logo and all its other products.

In this release, we have a new logo in a new color, and the terminal banner has been redesigned to match the current branding more closely.

Grafana k6 logo

New experimental CSV module for efficient CSV data handling #3743

We’ve added a new experimental CSV module to k6 for more efficient and convenient CSV parsing and streaming, addressing the limitations of preexisting JavaScript-based solutions like papaparse.

What is it?

The CSV module offers two key features:

Benefits for users

Tradeoffs

Example usage

Expand to see an example of Parsing a full CSV file into a SharedArray.
import { open } from 'k6/experimental/fs'
import csv from 'k6/experimental/csv'
import { scenario } from 'k6/execution'

export const options = {
    iterations: 10,
}

let file;
let csvRecords;
(async function () {
    file = await open('data.csv');

    // The `csv.parse` function consumes the entire file at once, and returns
    // the parsed records as a SharedArray object.
    csvRecords = await csv.parse(file, {delimiter: ','})
})();


export default async function() {
    // The csvRecords a SharedArray. Each element is a record from the CSV file, represented as an array
    // where each element is a field from the CSV record.
    //
    // Thus, `csvRecords[scenario.iterationInTest]` will give us the record for the current iteration.
    console.log(csvRecords[scenario.iterationInTest])
}
Expand to see an example of streaming a CSV file line-by-line.
import { open } from 'k6/experimental/fs'
import csv from 'k6/experimental/csv'

export const options = {
    iterations: 10,
}

let file;
let parser;
(async function () {
    file = await open('data.csv');
    parser = new csv.Parser(file);
})();

export default async function() {
    // The parser `next` method attempts to read the next row from the CSV file.
    //
    // It returns an iterator-like object with a `done` property that indicates whether
    // there are more rows to read, and a `value` property that contains the row fields
    // as an array.
    const {done, value} = await parser.next();
    if (done) {
        throw new Error("No more rows to read");
    }

    // We expect the `value` property to be an array of strings, where each string is a field
    // from the CSV record.
    console.log(done, value);
}

New k6 cloud run --local-execution flag for local execution of cloud tests #3904, and #3931

This release introduces the --local-execution flag for the k6 cloud run command, allowing you to run test executions locally while sending metrics to Grafana Cloud k6.

k6 cloud run --local-execution script.js

By default, using the --local-execution flag uploads the test archive to Grafana Cloud k6. If you want to disable this upload, use the --no-archive-upload flag.

The --local-execution flag currently functions similarly to the k6 run -o cloud command, which is now considered deprecated (though it is not planned to be removed). Future updates will enhance --local-execution with additional capabilities that the k6 run -o cloud command does not offer.

New k6 cloud upload command for uploading test files to the cloud #3906

We continue to refine and improve the cloud service to improve how we handle uploading test files, so we've added a new k6 cloud upload command that replaces the k6 cloud --upload-only flag, which is now considered deprecated.

gRPC module updates driven by contributors

New discardResponseMessage option

#3877 and #3820 add a new option for the gRPC module discardResponseMessage, which allows users to discard the messages received from the server.

const resp = client.invoke('main.RouteGuide/GetFeature', req, {discardResponseMessage: true});

This reduces the amount of memory required and the amount of garbage collection, which reduces the load on the testing machine and can help produce more reliable test results.

Thank you, @lzakharov!

New argument meta for gRPC's stream callbacks

#3801 adds a new argument meta to gRPC's stream callback, which handles the timestamp of the original event (for example, when a message has been received).

let stream = new grpc.Stream(client, "main.FeatureExplorer/ListFeatures")
stream.on('data', function (data, meta) {
    // will print the timestamp when message has been received
    call(meta.ts);
});

Thank you, @cchamplin!

Allow missing file descriptors for gRPC reflection

#3871 allows missing file descriptors for gRPC reflection.

Thank you, @Lordnibbler!

Sobek updates brings support of new ECMAScript features into k6 #3899, #3925, #3913

With this release, we've updated Sobek (the ECMAScript implementation in Go) which contains the new ECMAScript features that are now available in k6.

This includes support for numeric literal separators:

const billion = 1_000_000_000

Support for BigInt, the values which are too large to be represented by the number primitive:

const huge = BigInt(9007199254740991);

Note: Before k6 version v0.54, Golang's type math/big.Int mapped to another type, so this might be a breaking change for some extensions or users.

RegExp dotAll support, where you can match newline characters with .:

const str1 = "bar\nexample foo example";

const regex1 = /bar.example/s;

console.log(regex1.dotAll); // true

Support for ES2023 Array methods: with, toSpliced, toReversed and toSorted.

Thank you @shiroyk for adding both the new array methods and BitInt :bow:.

New setChecked method for the browser module browser#1403

Previously, users could check or uncheck checkbox and radio button elements using the check and uncheck methods. Now, we've added a setChecked method that allows users to set a checkbox or radio button to either the checked or unchecked state with a single method and a boolean argument.

await page.setChecked('#checkbox', true);   // check the checkbox
await page.setChecked('#checkbox', false);  // uncheck the checkbox

Page, Frame, ElementHandle, and Locator now support the new setChecked method.

Async check function utility k6-utils#13

Writing concise code can be difficult when using the k6 check function with async code since it doesn't support async APIs. A solution that we have suggested so far is to declare a temporary variable, wait for the value that is to be checked, and then check the result later. However, this approach can clutter the code with single-use declarations and unnecessary variable names, for example:

const checked = await p.locator('.checked').isChecked();

check(checked, {
    'checked': c => c,
});

To address this limitation, we've added a version of the check function to jslib.k6.io that makes working with async/await simpler. The check function is a drop-in replacement for the built-in check, with added support for async code. Any Promises will be awaited, and the result is reported once the operation has been completed:

// Import the new check function from jslib.k6.io/k6-utils
import { check } from 'https://jslib.k6.io/k6-utils/1.5.0/index.js';

// ...

// Use the new check function with async code
check(page, {
    'checked': async p => p.locator('.checked').isChecked(),
});

Check out the check utility function's documentation for more information on how to use it.

k6/experimnetal/websockets updates towards WebSockets API compatibility

Support ArrayBufferViews in send for k6/experimental/websockets #3944

As part of making k6/experimental/websockets compliant with the WebSocket API, it now supports Uint8Array and other ArrayBufferViews directly as arguments to send, instead of having to specifically provide their buffer.

This should make the module more compliant with libraries that use the WebSocket API.

Thanks to @pixeldrew for reporting this. :bow:

readyState actually being a number #3972

Due to goja/Sobek internal workings, readyState wasn't exactly a number in JavaScript code. This had some abnormal behavior, which limited interoperability with libraries.

This has been fixed, and readyState is a regular number from the JavaScript perspective.

Thanks to @dougw-bc for reporting this. :bow:

Rework of how usage is being collected internally and additional counters #3917 and #3951

As part of working on k6 over the years, we have often wondered if users use certain features or if they see a strange corner case behavior.

We have usually made guesses or tried to extrapolate from experience on issues we see. Unfortunately, this isn't always easy or possible, and it's definitely very skewed. As such, we usually also add warning messages to things we intend to break to inform people and ask them to report problems. But we usually see very little activity, especially before we make changes.

This also only works for things we want to remove, and it doesn't help us know if people use new functionality at all or if there are patterns we don't expect.

While k6 has been collecting usage for a while, they're surface-level things, such as how many VUs were run, the k6 version, or which internal modules were loaded. The system for this was also very rigid, requiring a lot of work to add simple things, such as if someone used the require function.

This process has been reworked to make things easier, and a few new usage reports have been added:

UX improvements and enhancements

Bug fixes

Maintenance and internal improvements

Roadmap

In version 0.52.0, the browser module transitioned from experimental to stable. The new module is more stable and has a full Async API. To ensure your scripts continue working, you must migrate to the new k6/browser module and discontinue using the previous k6/experimental/browser module. Please see the migration guide for more details.

相关地址:原始地址 下载(tar) 下载(zip)

1、 k6-v0.54.0-checksums.txt 754B

2、 k6-v0.54.0-linux-amd64.deb 26.96MB

3、 k6-v0.54.0-linux-amd64.rpm 29.58MB

4、 k6-v0.54.0-linux-amd64.tar.gz 28.42MB

5、 k6-v0.54.0-linux-arm64.tar.gz 26.75MB

6、 k6-v0.54.0-macos-amd64.zip 28.44MB

7、 k6-v0.54.0-macos-arm64.zip 27.29MB

8、 k6-v0.54.0-spdx.json 236.77KB

9、 k6-v0.54.0-windows-amd64.msi 29.24MB

10、 k6-v0.54.0-windows-amd64.zip 28.67MB

查看:2024-09-30发行的版本