Updates & News 28 February 2023

From the newsletter - k6 v0.43, async/await, browser and tracing, Prometheus dashboard, and more

k6 Team

Here is the first roundup of 2023, including a new k6 release, the latest developments in the k6 ecosystem, and news from the community. High time for a big update from your k6 amigos!

🙌 v0.43 released

v0.43 contains two releases which includes v0.43.0 and v0.43.1. v0.43.0 brings one of the most demanded k6 features: a friendlier syntax for working with asynchronous functionality via Javascript's async and await.

The lack of await support made using asynchronous functions inconvenient in k6. You needed to use the then() API to resolve a Promise and needed to design the k6 test as a nested Promise chain. Here’s a dummy example of an async client:

DB.connect(options).then((client) => {
client.insert('my-key', value).then((newValue, error) => {
});
});
// continues execution without waiting for Promise completion

Now with await, k6 can wait for the Promise to get its value, so you could write the previous test as:

const client = await DB.connect(options);
let newValue = await client.insert('my-key', value);

This release also includes a way to make asynchronous HTTP requests using http.asyncRequest to return a Promise. In future releases, we plan to introduce more k6 asynchronous APIs.

Distributed tracing

This release also includes a new experimental module to instrument HTTP requests with tracing data, supporting W3C or Jaeger traces. If you instrument your applications in the same way, you can now pinpoint the specific k6 traces in your observability (“o11y”) stack.

import tracing from 'k6/experimental/tracing'
import http from 'k6/http'
// sets all k6/http requests to include a trace context
tracing.instrumentHTTP({
propagator: 'w3c',
})
export default () => {
http.get('https://httpbin.test.k6.io/get')
}

To learn more, check out the tracing module documentation.

More fixes and improvements in this k6 version can be found in the following release notes:

🌐 k6 Browser

xk6-browser, our extension that adds browser-level APIs to enable browser automation, is now bundled in k6 as an experimental module! 🙌🏼

This further simplifies browser automation and frontend performance since it’s now a core part of k6. You no longer need to create a custom binary of k6 or use a separate run command to run your browser tests.

Going forward, xk6-browser will be referred to as k6 browser or simply the browser module now that it's bundled in k6 natively.

To learn more about why the team decided to merge xk6-browser to k6 core, as well as the changes to your browser test scripts, check out our k6 browser module announcement blog post.

☁️ k6 Cloud

The k6 Cloud team is now entirely focused on bringing the k6 Cloud experience to Grafana Cloud. The benefits of closer integration within your o11y stack are huge. To start, you'll gain better visibility between your testing and the system's performance, and there's no longer the need to switch between different platforms.

Grafana Cloud k6 Preview
Grafana Cloud k6 screenshots

Soon, Grafana Cloud users will be able to access most of the k6 Cloud capabilities within Grafana Cloud. Stay tuned for new announcements!

🔧 k6-operator

The k6-operator, the Kubernetes operator for running distributed k6 tests, has received some love these days! We've finally started resolving idempotency in the operator (#138), which is an umbrella epic for faulty cases related to timing and the state of test runs. Major improvements were made by @ivanape, including providing support for simultaneous tests execution without cloud output.

Other updates since v0.0.7 include:

  • Support for new features: envFrom, imagePullPolicy, imagePullSecrets.
  • Improved integration with the Distributed Application Runtime (Dapr) project.
  • Bug fixes, other small improvements, and documentation.

For a full list of features and fixes, check out the release notes for v0.0.8 and v0.0.9rc3.

Be sure to watch Office Hours #72, which provided a demonstration of the k6-operator that you can run locally as well!

💥 xk6-disruptor

xk6-disruptor is one of the latest offerings from k6. The latest release brought support in Windows and within a Kubernetes cluster.

If your application runs in Kubernetes, this extension allows your k6 tests to inject HTTP failures at the application level.

const fault = {
averageDelay: 100,
errorRate: 0.1,
errorCode: 500,
};
const svcDisruptor = new ServiceDisruptor('my-app', 'my-ns');
svcDisruptor.injectHTTPFaults(fault, 60);

This previous example disrupts the my-app service for 60 seconds. The disrupted service will respond with a 100ms delay and fail 10% of responses by returning the 500 HTTP status code.

With xk6-disruptor, you can more easily test how your application behaves when these errors occur.

⚙️ k6 Extensions

Our community of developers has been busy working on various extensions. At least 8 extensions have been updated while 4 new ones have been created!

  • xk6-distributed-tracing received some fixes for W3C compliance given its promotion to k6 core as an experimental module.

  • xk6-amqp migrated from a non-supported client to a maintained fork.

  • xk6-output-timescaledb received updates for batch handling thanks to a contribution from @miscjo.

  • xk6-output-influxdb was updated to remove strict reliance on the os package for accessing environment variables. This allows for easier unit testing.

From the community…

Once again, to our tireless community of extension developers: We see you and thank you!!!

🗞️ Must-reads

📺 Must watch

Happy testing!

-The k6 team

< Back to all posts