https://github.com/epomatti/stressbox
Swiss-army-knife Docker image for testing your containerized infrastructure.
https://github.com/epomatti/stressbox
autoscaling docker go golang load-testing stress-testing
Last synced: 4 months ago
JSON representation
Swiss-army-knife Docker image for testing your containerized infrastructure.
- Host: GitHub
- URL: https://github.com/epomatti/stressbox
- Owner: epomatti
- License: mit
- Created: 2023-06-25T22:39:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-07T22:25:20.000Z (almost 2 years ago)
- Last Synced: 2025-01-17T18:34:55.389Z (12 months ago)
- Topics: autoscaling, docker, go, golang, load-testing, stress-testing
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stressbox

[](https://codecov.io/gh/epomatti/stressbox) [](https://goreportcard.com/report/github.com/epomatti/stressbox) [](https://codebeat.co/projects/github-com-epomatti-stressbox-main)
Stressbox is a small Docker utility for Cloud Engineers and SREs that conveniently assists on testing common scenarios involving containerized infrastructure.
- **Load testing** - Simulate high CPU or memory usage to trigger autoscaling and alarms.
- **Stress testing** - Force stress test scenarios and observe the cluster resiliency.
- **Networking/firewall** - Test firewall rules and connectivity requirements within your infrastructure.
Check the [Private repositories](#private-repositories) section for examples on how to deploy the image to your cluster.
## Endpoints
Stressbox has a web interface. Deploy the image to your cluster and use the endpoints:
| Endpoint | Functionality | Example |
|----------|-------------|---------|
| /cpu?x={n} | Stresses the CPU by a factor of "x" | `curl 127.1:8080/cpu?x=42` |
| /mem?add={mb} | Increases the used memory in megabytes | `curl 127.1:8080/mem?add=100` |
| /tcp?addr={addr} | Tests a target TCP connection | `curl 127.1:8080/tcp?addr=google.com:443` |
| /envs?env={var} | Returns an environment variable | `curl 127.1:8080/envs?env=DB_NAME` |
| /json?size={n} | Returns a JSON batch of size "n" | `curl 127.1:8080/json?size=10000` |
| /exit | Exits the application | `curl 127.1:8080/exit` |
| /log?={m} | Writes to standard out | `curl 127.1:8080/log?m=Hello` |
| / | Returns a static OK | `curl 127.1:8080/` |
## Getting started
Running the image locally is an easy way to get to know the toolbox:
Pull the image:
```sh
docker pull ghcr.io/epomatti/stressbox
```
An `ARM64` release is now available on Docker Hub:
```sh
docker pull epomatti/stressbox:arm64
```
Start the container:
> 💡 Add `-e port=` to start the listener in another port
```sh
docker run -p 8080:8080 ghcr.io/epomatti/stressbox
```
Call the `/cpu` endpoint to simulate high CPU usage:
```
curl localhost:8080/cpu?x=30
```
The `x` parameter is a simple Fibonacci length, adjust to your requirements.
## Load testing
Choose your favorite load testing tool. Here's an example with K6:
```js
// script.js
import http from 'k6/http';
import { sleep } from 'k6';
const URL = __ENV.URL
console.log(`Calling ${URL}`);
export default function () {
const res = http.get(URL);
sleep(0);
}
```
Running the load testing:
```sh
k6 run -e URL="https://yourserver/cpu?x=30" --vus 10 --duration 300s script.js
```
## Private repositories
Command samples to upload this image to your docker repository:
### AWS Elastic Container Registry (ECR)
```sh
docker pull ghcr.io/epomatti/stressbox
docker tag ghcr.io/epomatti/stressbox "$account.dkr.ecr.$region.amazonaws.com/stressbox:latest"
aws ecr get-login-password --region $region | docker login --username AWS --password-stdin "$account.dkr.ecr.$region.amazonaws.com"
docker push "$account.dkr.ecr.$region.amazonaws.com/stressbox:latest"
```
### Azure Container Registry (ACR)
```sh
az acr login --name "$acr"
docker pull ghcr.io/epomatti/stressbox
docker tag ghcr.io/epomatti/stressbox "$acr.azurecr.io/$repository:latest"
docker push "$acr.azurecr.io/$repository:latest"
```