Overview
xk6-disruptor implements the principles of Chaos Engineering to test how your applications handle:- Network delays and latency
- HTTP and gRPC errors
- Service degradation
- Partial failures
- Everything as code - Write fault injection tests in JavaScript alongside your performance tests
- Fast to adopt - No need to deploy and maintain a fleet of agents or operators
- Easy to integrate - Works seamlessly with other k6 tests
Capabilities
Currently, the disruptor is designed for applications running in Kubernetes. Other platforms are not supported at this time. The extension provides a JavaScript API to inject different faults in HTTP and gRPC requests:- Error injection - Return specific HTTP status codes or gRPC error codes
- Delay injection - Add latency to requests
- Target selection - Inject faults into specific Pods or Services
Use cases
xk6-disruptor helps you test application resilience:Resilience policies
Test backoff, timeouts, retries, and circuit breakers
Fallback functionality
Verify graceful degradation when dependencies fail
SLO validation
Test SLOs under common internal failures
Performance under stress
Measure application performance with injected delays
The disruptor focuses on reproducing the side effects of failures (errors, delays) rather than root causes (failed instances, resource exhaustion). This makes tests repeatable and predictable while limiting their blast radius.
Installation
There are three ways to use xk6-disruptor:Download a release binary
The quickest way to get started:Build from source with Go
This creates anxk6-disruptor binary in the current directory.
Build with Docker
Quick start
Here’s a simple example that injects faults into a Kubernetes service:API overview
xk6-disruptor provides two main disruptor types:ServiceDisruptor
Targets a Kubernetes Service and all its backend Pods:PodDisruptor
Targets specific Pods matching a selector:Fault types
Both HTTP and gRPC fault injection support:
Example with all options:
Combining with load tests
xk6-disruptor works seamlessly with k6 load testing:Requirements
To use xk6-disruptor, you need:- Kubernetes cluster - Access to a Kubernetes cluster (1.23+)
- kubectl access - Configured kubeconfig with permissions to:
- Create/delete Pods
- Read Services and Pods
- Execute commands in Pods
- Network policies - Cluster must allow Pod-to-Pod communication
Interactive demo
Try xk6-disruptor without any setup: Launch interactive demo on Killercoda The demo provides a fully configured environment with a sample application.Learn more
GitHub Repository
Source code and detailed documentation
Roadmap
Upcoming features and enhancements
Contributing
Contribute to the project
Blog: Fault Injection
Learn about fault injection principles
Examples
Test retry logic
Test timeout handling
Progressive fault injection
Troubleshooting
Check cluster connectivity
Verify permissions
Debug disruptor issues
Enable debug logging in your test:Next steps
Build Custom Binary
Bundle xk6-disruptor with other extensions
Explore Extensions
Discover more k6 extensions
Browser Extension
Add browser testing to your suite
Community Forum
Get help and share experiences