A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Recent Posts

Archive

Archives for bundling/sharing a test

What is an archive?

When the complexity of a k6 test goes beyond a single JS file it quickly becomes cumbersome to find and bundle up all the dependencies (JS, open()'ed data files, TLS client certs etc.). There is a need for a native way to bundle and distribute/share a test. That is what k6 archives are for.

A k6 archive is simply a tar file with all files needed to execute a k6 test.

How to create and run an archive

Now if you replace run with archive k6 will run the init stage of the code to determine which JS files are being imported and what data files are being open()'ed and bundles all of the files up into a tar file:

Overriding options

Use cases

Archive files have a variety of use cases, but they all share the common need to bundle of a test's files into a single file for easy distribution.

Sharing a testBy bundling up a test into an archive it's easy to share the test with your team mates by simply storing or sending a single tar file. As we saw in the previous section, your team mates can execute the archive by running k6 run archive.tar.

Preparing tests for CIIf you have a complex CI pipeline and your load tests are separated from your application code, you could store k6 archives as build artefacts whenever the load test source code is changed, and then pull in those k6 archives from the artefacts storage for test execution as needed.

Load Impact Cloud ExecutionLoad Impact offers a commercial service for running large scale and geographically distributed load tests on managed cloud infrastructure. Cloud executed tests are triggered from the k6 command-line via the k6 cloud script.js command (similar to k6 run) which will trigger an implicit creation of a k6 archive that is uploaded and distributed to Load Impact load generators for execution.

Clustered Execution (future)In the future (roadmap) k6 will support a clustered execution mode that will enable tests to be run across more than one node. This mode of execution is also likely to make use of the archive functionality to distribute the test files to all participating nodes.

Now, if the current working directory is /home/johndoe/tests/api-test/ and we run k6 archive script.js we'd get a tar file called archive.tar (you can change the name of the file using -O filename.tar). The contents of the archive.tar would look like something like this: