This application is a set of handy APIs to simulate the various response scenarios like high CPU consumption, high memory consumption, high disk usage, application crash... etc.
You may use this application to test your microservices deployment environment, reverse proxy, monitoring infrastructure by simulating some abnormal behaviors from a specific container or multiple containers.
- Ensure you have Docker installed. If not you may use this repo to install Docker with just one command.
- Spin up a container
sudo docker run -d --rm -p 5001:80 jinweijiedocker/simulation-api
. - You have the APIs available on port 5001 on your local host.
- Test the API with
curl http://localhost:5001/delay
.
- Ensure you have Docker and Docker Compose installed. If not you may use this repo to install Docker and Docker Compose with just one command.
- Clone this repository
git clone https://github.com/jinweijie/SimulationApi.git
andcd SimulationApi
. - Since there is the docker-compose.yml file in this repo, you can just run
sudo docker compose up -d
(If you're using the olddocker-compose
, then you need to runsudo docker-compose up -d
) and then you will have 3 containers running on port5001
,5002
,5003
.
You need to add your host and port prefix. For example, if you are running this application on http://localhost:5001
, to use the delay endpoint with parameter 5, the full url will be http://localhost:5001/delay/5
.
/
- Display system information./delay/{ms:int?}
- Simulate a slow response with specific milliseconds, default is 3000./delay/{msMin:int}/{msMax:int}
- Simulate a slow response with random milliseconds betweenmsMin
andmsMax
./cpu/{seconds:int?}/{percentage:int?}
- Simulate high CPU utilization. For example, to simulate 100% CPU utilization for 5 seconds, you can either accesshttp://localhost:5001/5/100
with browser or use command linecurl http://localhost:5001/5/100
./memory/{seconds:int?}/{sizeInM:int?}
- Simulate high memory usage./disk/{seconds:int?}/{sizeInM:int?}
- Simulate high disk usage. This endpoint will create a dummy file based on the size ofsizeInM
and delete afterseconds
./{statusCode:int}
- Return the status code. For example,http://localhost:5001/401
will return status code 401./exception/{probability:int}
- Simulate random exception based on theprobability
provided./exception
- Simulate the server side exception every time./crash/{probability:int?}
- Simulate application crash based on theprobability
provided./crash
- Simulate application crash every time./exit
- Simulate application normal exit (exit code 0).
If you would like to support my development, feel free to buy me a coffee, it makes a big difference! Thanks.