MyGit

v0.43.0

grafana/k6

版本发布时间: 2023-02-20 19:24:31

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

k6 v0.43.0 is here! :tada:

Notable changes in this release include:

Keep reading for the details.

Breaking changes

New Features

xk6-browser is now a built-in module #2884

This release includes xk6-browser as an experimental module. This means you can now also use the main k6 binary for browser automation and end-to-end testing, without needing to build a custom binary with xk6.

All xk6-browser scripts that work with v0.8.0 will continue to work with the built-in module in k6 v0.43.0. To use them, change the import path from k6/x/browser to k6/experimental/browser, and set the environment variable K6_BROWSER_ENABLED to true. The requirement to specify the environment variable is temporary and may be removed in a future k6 release. It was added to minimize the risks with k6 unexpectedly launching a browser (or another process) from k6 scripts. It's also a mechanism we use in the k6 Cloud, where browser tests are currently disabled.

For details, review the script example, or the updated browser module documentation.

The module is currently under the experimental namespace, which means we reserve the decision to introduce breaking changes in the future. However, our mid-term goal is to drop the experimental label and make browser support a stable part of the k6 feature set, eventually enabling it in k6 Cloud as well.

Native support for JavaScript's async/await #2830

In v0.35.0 we added support for asynchronous functionality in k6 scripts with the addition of Promise.

While useful, the experience wasn't very friendly. Scripts had to use the .then() API to chain Promises, instead of the await syntax available in most other JavaScript runtimes, and the async keyword wasn't supported. Some workarounds were possible, but it required a separate build pipeline to transpile the syntax into the older ES5.1+ standard supported by k6.

That is, until now! :tada: With invaluable help from @dop251, who maintains goja, the JS VM k6 uses, v0.43.0 brings native async/await to your k6 scripts. This functionality works just as you'd expect in other JS runtimes, and makes working with async APIs much more convenient. For details, review the following http.asyncRequest() example.

One caveat to note: async functions can't be passed to group() or check(). These functions are incompatible with asynchronous behavior, so you will get an error if trying to do so.

Experimental JavaScript module for distributed tracing #2853 #2854 #2855

This release brings a new experimental JavaScript module that adds distributed tracing support to k6. With one call in init context, you can instrument your test script's HTTP requests. If the system you're testing is instrumented in the same way, this module brings visibility to SUT behavior for the lifetime of each request.

An example:

import tracing from 'k6/experimental/tracing';
import http from 'k6/http';

tracing.instrumentHTTP({
  propagator: 'w3c',
});

export default () => {
  http.get('https://httpbin.test.k6.io/get', {
    headers: {
      'X-Example-Header': 'instrumented/get',
    },
  });
};

For details and examples, refer to the tracing module documentation.

http.asyncRequest #2877

The k6/http module has a new asyncRequest function that takes the same arguments as http.request(), but returns a Promise that, when used with await, will be resolved with a Response object. This gives you more control over script execution, as potentially the most time-consuming calls—making HTTP requests—will no longer block the thread of execution.

An example issuing a POST request:

import http from 'k6/http';

export default async function () {
  const resPromise = http.asyncRequest(
    'POST', 'https://httpbin.test.k6.io/post', { name: 'Bert' });
  // Do something else here, make other requests, etc.
  // Then when you're ready to use the response:
  const resp = await resPromise;
  console.log(resp.json().form.name); // Bert
}

This is one of the first steps towards migrating our APIs to be asynchronous, and similar changes can be expected in the future.

You can read more about asyncRequest in the documentation.

Enhancements and UX improvements

Bug fixes

Maintenance and internal improvements

Full Changelog: https://github.com/grafana/k6/compare/v0.42.0...v0.43.0

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

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

2、 k6-v0.43.0-linux-amd64.deb 20.35MB

3、 k6-v0.43.0-linux-amd64.rpm 22.35MB

4、 k6-v0.43.0-linux-amd64.tar.gz 21.47MB

5、 k6-v0.43.0-linux-arm64.tar.gz 20.11MB

6、 k6-v0.43.0-macos-amd64.zip 21.13MB

7、 k6-v0.43.0-macos-arm64.zip 20.47MB

8、 k6-v0.43.0-windows-amd64.msi 22MB

9、 k6-v0.43.0-windows-amd64.zip 21.59MB

查看:2023-02-20发行的版本