k6 archive format
A k6 archive is a self-contained bundle that includes your test script and all its dependencies. Archives are useful for:- Distributing tests to multiple machines
- Ensuring consistent test execution across environments
- Running tests in air-gapped or restricted environments
- Sharing tests with your team
Creating an archive
Use thek6 archive command to create an archive:
archive.tar file containing:
- Your test script
- All imported modules and dependencies
- Metadata about the test
Specify output file
Include external files
If your test usesopen() to load external files, k6 automatically includes them in the archive:
Running from an archive
Execute tests directly from an archive:Archive structure
A k6 archive is a tar file with this structure:Metadata
Themetadata.json file contains:
- Test options (VUs, duration, thresholds, etc.)
- Script filename
- Environment information
- k6 version used to create the archive
Use cases
Distributed testing
Create an archive once and distribute it to multiple test runners for consistent execution.
CI/CD pipelines
Build archives as artifacts and run them in different stages of your pipeline.
Air-gapped environments
Transfer archives to restricted networks where dependencies can’t be downloaded.
Version control
Store archives alongside your code to ensure reproducible test runs.
Example workflow
Best practices
Keep archives small
Keep archives small
Only include necessary dependencies. Large archives take longer to transfer and extract.
Document requirements
Document requirements
Include a README with the archive specifying any external requirements or configuration needed.
Test before distribution
Test before distribution
Always test your archive locally before distributing it to ensure all dependencies are included.
Use with environment variables
Use with environment variables
Archives work well with environment variables for configuration:
Limitations
- Archives are not compressed by default (use gzip if needed)
- Binary extensions are not included in archives
- Archives contain absolute file paths from creation time
Related resources
Distributed tests
Running tests across multiple machines
Automated testing
Integrating k6 with CI/CD