Docker container to make runtime and platforms tests easy π³ π¦ π
π Homepage
β¨ Demo
docker run -it -p 8080:8080 fidelissauro/chip:v1
go get -u
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
go test
- Development environment uses air project to execute live reload on
.go
files.
docker-compose up --force-recreate
docker build -it chip
docker run -it -p 8080:8080 msfidelis/chip:v1
check on http://localhost:8080/swagger/index.html
Common healthcheck, dummy mock
curl 0.0.0.0:8080/healthcheck -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sat, 30 May 2020 22:43:11 GMT
Content-Length: 14
{"status":200}
Simulate error on Healthcheck
curl 0.0.0.0:8080/healthcheck/error -i
HTTP/1.1 503 Service Unavailable
Content-Type: application/json; charset=utf-8
Date: Sat, 30 May 2020 22:44:35 GMT
Content-Length: 14
{"status":503}
Use this for fault injection, circuit breaker, self healing tests on your readiness probe
while true; do curl 0.0.0.0:8080/healthcheck/fault; echo; done
{"status":503}
{"status":503}
{"status":200}
{"status":503}
{"status":503}
{"status":200}
{"status":503}
{"status":200}
{"status":200}
{"status":503}
{"status":503}
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":503}
{"status":200}
{"status":200}
{"status":200}
Cause ocasional failure in your probe
while true; do curl 0.0.0.0:8080/healthcheck/fault/soft; echo; done
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":200}
{"status":503}
{"status":200}
{"status":200}
{"status":503}
For Liveness tests
curl 0.0.0.0:8080/liveness -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sat, 08 May 2021 14:00:05 GMT
Content-Length: 17
{"status":"Live"}
curl 0.0.0.0:8080/liveness/error -i
HTTP/1.1 503 Service Unavailable
Content-Type: application/json; charset=utf-8
Date: Sat, 08 May 2021 14:01:08 GMT
Content-Length: 17
{"status":"Dead"}
For readiness tests
curl 0.0.0.0:8080/readiness -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sat, 08 May 2021 14:02:02 GMT
Content-Length: 18
{"status":"Ready"}
- You can set the environment variable
READINESS_PROBE_MOCK_TIME_IN_SECONDS
to customize your readiness probe in seconds for testing. Default is 5 seconds.
curl 0.0.0.0:8080/readiness/error -i
HTTP/1.1 503 Service Unavailable
Content-Type: application/json; charset=utf-8
Date: Sat, 08 May 2021 14:02:37 GMT
Content-Length: 22
{"status":"Not Ready"}
This endpoint return different values in accord to tag version, v1, v2, v1-blue, v1-green, v2-blue and v2-green. Ideal to tests deployment scenarios behavior, like rollout, canary, blue / green etc.
This variable can be customized using environment variable called `VERSION``
export VERSION=v3
curl 0.0.0.0:8080/version -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sun, 31 May 2020 03:38:21 GMT
Content-Length: 16
{"version":"v1"}
Retrieve some system info. Use this to test memory, cpu limits and isolation. Host name for load balancing tests and etc.
curl 0.0.0.0:8080/system -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sun, 31 May 2020 03:33:12 GMT
Content-Length: 76
{"hostname":"21672316d98d","cpus":2,"os":"","hypervisor":"bhyve","memory":0}
curl http://0.0.0.0:8080/system/environment -i
[
"HOSTNAME=78339a8484d4",
"HOME=/root",
"ENVIRONMENT=dev",
"PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOPATH=/go",
"PWD=/go/src/chip",
"GOLANG_VERSION=1.13.11"
]
Use this endpoint to retrieve request headers, body, querystrings, cookies, etc. Ideal to tests API Gateway, CDN, Proxys, Load Balancers transformations on request. Available for all HTTP methods
curl -X GET 0.0.0.0:8080/reflect -i
{
"method": "GET",
"params": "",
"headers": {
"Accept": [
"*/*"
],
"User-Agent": [
"curl/7.64.1"
]
},
"cookies": [],
"body": "",
"path": "/reflection"
}
Use this endpoint to proxy HTTP requests betweet chip and another endpoint
curl --location --request POST 'http://0.0.0.0:8080/proxy' \ ββ―
--header 'Content-Type: application/json' \
--data-raw '{
"method": "GET",
"host": "https://google.com.br/",
"path": "/whoami",
"headers": [
{
"name": "content-type",
"value": "application/json"
},
{
"name": "foo",
"value": "bar"
}
],
"body": "{\"vai\": \"sim\"}"
}'
curl -X POST "0.0.0.0:8080/reflection?id=1" -H "Header-Foo: Bar" -d '{"foo":"bar"}' | jq .
{
"method": "POST",
"params": "id=1",
"headers": {
"Accept": [
"*/*"
],
"Content-Length": [
"13"
],
"Content-Type": [
"application/x-www-form-urlencoded"
],
"Header-Foo": [
"Bar"
],
"User-Agent": [
"curl/7.64.1"
]
},
"cookies": [],
"body": "{\"foo\":\"bar\"}",
"path": "/reflection"
}
Use this endpoint to consume some CPU resources. Ideal to test auto scale policies, isolation, monitoring and alerts behaviors.
Danger
curl -X GET 0.0.0.0:8080/burn/cpu -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Tue, 02 Jun 2020 04:42:24 GMT
Content-Length: 20
{"status":"On Fire"}
curl -X GET 0.0.0.0:8080/burn/ram -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Tue, 02 Jun 2020 04:42:24 GMT
Content-Length: 20
{"status":"On Fire"}
Check connection between container environment / namespace and services and another applications
curl -X GET 0.0.0.0:8080/ping/google.com/80 -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Mon, 20 Jul 2020 16:04:02 GMT
Content-Length: 71
{"host":"google.com","port":"80","protocol":"tcp","status":"connected"}
Sent a log of logs to stdout. Sent querystring events
to customize the number of logs; Default 1000
.
curl -X GET "0.0.0.0:8080/logging?events=2000" -i
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sat, 28 Aug 2021 14:50:41 GMT
Content-Length: 61
{"status":200,"message":"2000 logging events sent to stdout"}
List some directory contents
curl -X POST "0.0.0.0:8080/filesystem/ls" -i -d '{"path": "./"}'
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Fri, 10 Jan 2025 11:52:26 GMT
Content-Length: 86
{"path":"./","files":[".dockerenv","dev","etc","lib","main","proc","sys","tmp","var"]}
Write file - base64 content
curl -X POST "0.0.0.0:8080/filesystem/write" -i -d '{"path": "./test", "content": "V3JpdGUgVGVzdAo="}';
HTTP/1.1 202 Accepted
Content-Type: application/json; charset=utf-8
Date: Fri, 10 Jan 2025 11:58:13 GMT
Content-Length: 42
{"message":"file written","path":"./test"}
Read files on filesystem
curl -X POST "0.0.0.0:8080/filesystem/cat" -i -d '{"path": "./test"}';
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Fri, 10 Jan 2025 11:58:44 GMT
Content-Length: 11
Write Test
Delete files on filesystem
curl -X DELETE "0.0.0.0:8080/filesystem/delete" -i -d '{"path": "./test"}';
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Fri, 10 Jan 2025 11:59:01 GMT
Content-Length: 26
{"message":"file deleted"}
curl -X GET 0.0.0.0:8080/whoami -i
HTTP/1.1 418 I'm a teapot
Content-Type: text/plain; charset=utf-8
Date: Sun, 23 May 2021 00:53:46 GMT
Content-Length: 85
;,'
_o_ ;:;'
,-.'---`.__ ;
((j`=====',-'
`-\ /
`-=-'
π€ Matheus Fidelis
- Website: https://raj.ninja
- Twitter: @fidelissauro
- Github: @msfidelis
- LinkedIn: @msfidelis
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a βοΈ if this project helped you!
Copyright Β© 2020 Matheus Fidelis.
This project is MIT licensed.
This README was generated with β€οΈ by readme-md-generator