https://github.com/aatarasoff/apistress
Very simple stress testing tool for API
https://github.com/aatarasoff/apistress
docker load-testing performance stress-testing test vegeta
Last synced: 4 months ago
JSON representation
Very simple stress testing tool for API
- Host: GitHub
- URL: https://github.com/aatarasoff/apistress
- Owner: aatarasoff
- License: mit
- Created: 2016-08-18T07:03:35.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-07-26T12:05:23.000Z (almost 9 years ago)
- Last Synced: 2025-10-29T04:29:04.475Z (8 months ago)
- Topics: docker, load-testing, performance, stress-testing, test, vegeta
- Language: Go
- Size: 10.7 KB
- Stars: 22
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# apistress
[](https://goreportcard.com/report/github.com/aatarasoff/apistress)
This is very simple stress testing tool for API based on [vegeta](https://github.com/tsenart/vegeta)
## Motivation
Sometimes you want to check SLA of your API automatically. There are many tools for profiling or stressing your software, but all of them have the enormous complexity or analyze results by third party tools. This project helps you do it easy and in a straightforward way. One configuration file with a simple structure is needed. In configuration file you need to declare the target, attack time, request frequency and (this is the most important part) SLA for target service (99th latency percentile and percentage of successful requests). And if any test is failed, the program will print report and exit with error code. It gives simple integration with different continuous delivery tools.
## Usage
Create file with name `config.json` and folowing structure:
```Go
{
"baseUrl": "http://localhost:8080", //base url for targets
"tests": [ //array of tests
{
"rps": 100, //target request per second
"duration": 1, //test duration
"target": {
"method": "POST", //http method for target url
"path": "/test", //relative path
"headers": [ //optional
{
"name": "X-Request-Id", //http header name
"value": "12345" //http header value
}
],
"body": "ewoic2F5IiA6ICJoZWxsbyIKfQ==" //base64 endoded request body (optional)
},
"sla": {
"latency": 150, //99 percenitle latency
"successRate": 99.9 //percentage of successful requests (2xx http code is returned)
}
}
]
}
```
Then run docker container:
```bash
docker run --rm --net=host \
-v /path/to/folder/with/config:/data \
aatarasoff/apistress
```
or with overriden `baseUrl` config property:
```bash
docker run --rm --net=host \
-v /path/to/folder/with/config:/data \
aatarasoff/apistress apistress \
-baseUrl http://custom.server:8080
```
If `stdin` input is required, use `-config=stdin` flag:
```bash
cat config.json | docker run --rm --net=host \
aatarasoff/apistress apistress \
-config=stdin
```
Also it is possible to define own config file name and path:
```bash
docker run --rm --net=host \
-v /path/to/folder/with/config:/data \
aatarasoff/apistress apistress \
-config=/path/to/folder/with/config/filename.json
```
For each test program prints metrics into `stdout`:
```bash
Requests [total, rate] 10, 11.11
Duration [total, attack, wait] 1.007898226s, 899.953255ms, 107.944971ms
Latencies [mean, 50, 95, 99, max] 108.246432ms, 107.608893ms, 109.534083ms, 109.534083ms, 112.276495ms
Bytes In [total, mean] 5750, 575.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:10
Error Set:
```
and returns exit code that you may check with following command:
```bash
echo $? //0 - ok, 1 - sla error
```
## Usage without Docker or developing
You need install and setup `golang` 1.6 or above with following [instructions](https://golang.org/doc/install). Then run:
```Go
go get
go install github.com/aatarasoff/apistress
```