2024-12-04 16:40:52 -06:00
|
|
|
# Loadr
|
|
|
|
|
|
|
|
A lightweight REST load testing tool with robust support for different request patterns, token auth, and performance reports.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
```bash
|
|
|
|
go build
|
|
|
|
```
|
|
|
|
|
|
|
|
## Quick Start
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Simple pattern: 5 POST requests
|
|
|
|
./loadr -rate=20 -max=100 -url=http://api.example.com -pattern=5p
|
|
|
|
|
|
|
|
# Mixed pattern: 1 POST followed by 5 GETs, repeating
|
|
|
|
./loadr -rate=20 -max=100 -url=http://api.example.com -pattern=1p5g
|
|
|
|
|
|
|
|
# With authentication and request body
|
|
|
|
./loadr -rate=20 -max=100 -url=http://api.example.com -pattern=2p3g -json=./data.json -token=YourBearerToken
|
|
|
|
```
|
|
|
|
|
|
|
|
## Request Patterns
|
|
|
|
|
|
|
|
The `-pattern` flag supports flexible request patterns:
|
|
|
|
|
|
|
|
### Simple Patterns
|
|
|
|
- `5p` : 5 POST requests
|
|
|
|
- `3g` : 3 GET requests
|
|
|
|
|
|
|
|
### Sequential Patterns
|
|
|
|
- `1p5g` : 1 POST followed by 5 GETs
|
|
|
|
- `2p3g` : 2 POSTs followed by 3 GETs
|
|
|
|
- `3g2p` : 3 GETs followed by 2 POSTs
|
|
|
|
|
2024-12-04 17:26:34 -06:00
|
|
|
### Probabalistic Patterns
|
|
|
|
- `20%p80%g` : 20% POST and by 80% GETs
|
|
|
|
|
2024-12-04 16:40:52 -06:00
|
|
|
### Pattern Rules
|
|
|
|
- Numbers specify how many requests of each type
|
|
|
|
- 'p' or 'P' specifies POST requests
|
|
|
|
- 'g' or 'G' specifies GET requests
|
2024-12-04 17:26:34 -06:00
|
|
|
- '%' indicates probabilistic requests
|
2024-12-04 16:40:52 -06:00
|
|
|
- If no number is specified, 1 is assumed (e.g., "pg" = "1p1g")
|
|
|
|
- Pattern repeats until max requests is reached
|
|
|
|
|
|
|
|
## Command Line Flags
|
|
|
|
|
|
|
|
- `-rate`: Number of requests per second (default: 10)
|
|
|
|
- `-max`: Maximum number of requests to send (default: 50)
|
|
|
|
- `-url`: Target URL (default: "https://example.com")
|
2024-12-04 17:26:34 -06:00
|
|
|
- `-pattern`: Request pattern (e.g., "5p", "1p5g", "3g2p", "10%p90%g")
|
2024-12-04 16:40:52 -06:00
|
|
|
- `-json`: Path to JSON file for request body
|
|
|
|
- `-token`: Bearer token for authorization
|
|
|
|
- `-v`, `-version`: Print version information
|
|
|
|
|
|
|
|
## Reports
|
|
|
|
|
|
|
|
Test results are automatically:
|
|
|
|
1. Displayed in the console
|
|
|
|
2. Saved to `.reports/[timestamp].txt`
|
|
|
|
|
|
|
|
Reports include:
|
|
|
|
- Total requests sent and received
|
|
|
|
- Average, maximum, and minimum latency
|
|
|
|
- Requests per second (sent and received)
|
|
|
|
- Pattern information
|