Files
stroke/README.md
2025-09-12 17:01:54 +03:00

277 lines
7.5 KiB
Markdown

# 🚀 Stroke - Because Your Server Needs Some Exercise
[![Go Version](https://img.shields.io/badge/Go-1.25+-00ADD8?style=flat&logo=go)](https://golang.org)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Build Status](https://img.shields.io/badge/Build-Passing-brightgreen.svg)](https://git.gostacks.org/iwasforcedtobehere/stroke)
> *"Why call it stress testing when you can call it therapeutic violence?"*
**Stroke** is a high-performance, concurrent stress testing tool built in Go that'll make your APIs sweat harder than a programmer during a code review. It's designed to pummel your services with requests until they either break or prove they're worthy of production.
## 🎯 What the Fuck Does This Thing Do?
- **Concurrent Chaos**: Spawns an army of goroutines to bombard your endpoints
- **Smart Rate Limiting**: Won't crash your server (unless you want it to)
- **Detailed Metrics**: Numbers that'll make your performance graphs look professional AF
- **Failure Injection**: Because sometimes you need to see how things break
- **Beautiful Reports**: Charts so pretty you'll want to frame them
## 🛠️ Installation
Because life's too short for complicated installations:
```bash
go install git.gostacks.org/iwasforcedtobehere/stroke/cmd/stroke@latest
```
Or if you're the type who likes to build from source (respect):
```bash
git clone https://git.gostacks.org/iwasforcedtobehere/stroke
cd stroke
go build -o stroke ./cmd/stroke
```
## 🚦 Quick Start
### Basic Usage (For the Impatient)
```bash
# Hit an endpoint 1000 times with 50 concurrent workers
stroke -url https://api.example.com/health -requests 1000 -concurrency 50
# Ramp up like a proper stress test
stroke -url https://api.example.com/users -requests 5000 -concurrency 100 -ramp-up 30s
# Go absolutely nuclear (use responsibly)
stroke -url https://api.example.com/heavy-endpoint -requests 10000 -concurrency 200 -duration 5m
```
### Configuration File (For the Organized)
Create a `stroke-config.yaml` because YAML is sexy:
```yaml
target:
url: "https://api.yourservice.com/api/v1/users"
method: "POST"
headers:
Content-Type: "application/json"
Authorization: "Bearer your-token-here"
body: |
{
"username": "testuser",
"email": "test@example.com"
}
load:
requests: 10000
concurrency: 100
duration: "5m"
ramp_up: "30s"
pattern: "ramp" # constant, ramp, spike
rate_limiting:
enabled: true
requests_per_second: 500
failure_injection:
enabled: true
network_delay: "10ms"
drop_rate: 0.05 # 5% packet loss
error_rate: 0.02 # 2% server errors
reporting:
format: ["console", "json", "html"]
output_dir: "./results"
percentiles: [50, 90, 95, 99]
```
Then run it like a boss:
```bash
stroke -config stroke-config.yaml
```
## 📊 What You Get
### Real-time Console Output
```
🚀 Stroke v1.0.0 - Server Stress Testing Tool
Target: https://api.example.com/users
Workers: 100 | Total Requests: 10000
Progress: [████████████████████████████████████████] 100% | 10000/10000
Duration: 45.2s | RPS: 221.24 | Errors: 0.2%
Response Times:
Min: 12ms | Max: 2.1s | Avg: 156ms
p50: 145ms | p90: 312ms | p95: 567ms | p99: 1.2s
Status Codes:
200: 9978 (99.8%)
500: 22 (0.2%)
Fuck yeah! Your API handled it like a champ! 💪
```
### Detailed Reports
Stroke generates comprehensive reports that won't make you want to cry:
- **JSON**: For when you need to integrate with other tools
- **HTML**: Beautiful graphs that make stakeholders happy
- **Prometheus**: Because monitoring is life
- **CSV**: For the Excel warriors
## 🏗️ Architecture
### Core Components
```
stroke/
├── cmd/stroke/ # CLI application entry point
├── pkg/
│ ├── engine/ # Core stress testing engine
│ ├── metrics/ # Performance metrics collection
│ ├── config/ # Configuration management
│ └── reporter/ # Report generation
├── internal/
│ └── ratelimit/ # Rate limiting implementation
└── examples/ # Example configurations
```
### Key Features
- **Goroutine Pool**: Efficiently manages concurrent workers
- **Channel-based Communication**: Because channels are fucking beautiful
- **Context Cancellation**: Graceful shutdowns (we're not animals)
- **Memory Efficient**: Won't eat your RAM like Chrome
- **Race Condition Free**: Tested with `-race` flag
## 🔥 Advanced Features
### Load Patterns
```bash
# Constant load (boring but effective)
stroke -pattern constant -rps 100
# Ramp up (like a good workout)
stroke -pattern ramp -start-rps 10 -end-rps 1000 -duration 5m
# Spike testing (shock therapy for your API)
stroke -pattern spike -base-rps 100 -spike-rps 1000 -spike-duration 30s
```
### Failure Injection
Because sometimes you need to see how things break:
```bash
# Add network chaos
stroke -network-delay 50ms -packet-loss 0.1
# Simulate server errors
stroke -error-injection 0.05 # 5% error rate
```
### Custom Scenarios
Write your own test scenarios in Go:
```go
package main
import (
"git.gostacks.org/iwasforcedtobehere/stroke/pkg/engine"
"git.gostacks.org/iwasforcedtobehere/stroke/pkg/config"
)
func main() {
cfg := &config.Config{
Target: config.Target{
URL: "https://api.example.com",
Method: "POST",
},
Load: config.Load{
Concurrency: 50,
Requests: 1000,
},
}
engine := engine.New(cfg)
results := engine.Run()
// Do whatever the fuck you want with the results
fmt.Printf("Average response time: %v\n", results.AvgResponseTime)
}
```
## 🧪 Testing
We take testing seriously (unlike some people):
```bash
# Run all tests
go test ./...
# Run with race detection (because data races are evil)
go test -race ./...
# Benchmark tests (for the performance nerds)
go test -bench=. ./...
# Coverage report (aim for >80% or you're doing it wrong)
go test -cover ./...
```
## 🤝 Contributing
Found a bug? Want to add a feature? Pull requests are welcome!
1. Fork it (you know how this works)
2. Create your feature branch (`git checkout -b feature/awesome-feature`)
3. Write tests (seriously, don't be that person)
4. Commit your changes (`git commit -am 'Add some awesome feature'`)
5. Push to the branch (`git push origin feature/awesome-feature`)
6. Create a Pull Request
### Code Style
- Use `gofmt` (if you don't, we can't be friends)
- Write meaningful commit messages
- Comment your code (future you will thank you)
- No magic numbers (constants are your friend)
## 📝 License
MIT License - because sharing is caring.
## 🙏 Acknowledgments
- The Go team for creating a language that doesn't make me want to quit programming
- Coffee, for making this project possible
- Stack Overflow, for obvious reasons
- My rubber duck, for listening to my debugging sessions
## 🐛 Known Issues
- May cause addiction to performance testing
- Your servers might actually become faster (side effect)
- Could make other load testing tools jealous
## 📞 Support
Having issues? Check these in order:
1. Read the fucking manual (this README)
2. Check the [examples](./examples/) directory
3. Search existing issues on [GitStacks](https://git.gostacks.org/iwasforcedtobehere/stroke/issues)
4. Create a new issue with details (and please include logs)
---
**Made with ❤️ and a healthy dose of sarcasm by [@iwasforcedtobehere](https://git.gostacks.org/iwasforcedtobehere)**
*"Stroke: Because your servers deserve to know their limits."*