fix: Fix Tests and Add Healthcheck #22
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
api-test-monolithic: | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:19.03.12 | |
options: --privileged | |
steps: | |
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.22.2 | |
- name: "Install Deps" | |
run: | | |
sudo apt-get update | |
go mod download | |
go install github.com/k1LoW/runn/cmd/runn@latest | |
- name: "Start Server" | |
run: | | |
go run go/cmd/open-ve/main.go run --http-port=8080 & | |
- name: "Health Check" | |
run: | | |
for i in {1..10}; do | |
STATUS=$(curl -s http://localhost:8080/healthz | jq -r .status) | |
if [ "$STATUS" == "SERVING" ]; then | |
echo "Service is healthy!" | |
exit 0 | |
fi | |
echo "Waiting for the service to be healthy..." | |
sleep 5 | |
done | |
echo "Service did not become healthy in time." | |
exit 1 | |
- name: "Run runn" | |
run: | | |
export MONOLITHIC_ENDPOINT=http://0.0.0.0:8080 | |
make api-test-monolithic | |
api-test-master-slave: | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:19.03.12 | |
options: --privileged | |
steps: | |
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.22.2 | |
- name: "Install Deps" | |
run: | | |
sudo apt-get update | |
go mod download | |
go install github.com/k1LoW/runn/cmd/runn@latest | |
- name: "Start Master and Slave Server" | |
run: | | |
go run go/cmd/open-ve/main.go run --mode=master --http-port=8081 --grpc-port=9001 & | |
go run go/cmd/open-ve/main.go run --mode=slave --slave-id=slave-node-id --slave-master-http-addr=http://localhost:8081 --slave-slave-http-addr=http://localhost:8082 --http-port=8082 --grpc-port=9002 & | |
- name: "Health Check" | |
run: | | |
for i in {1..10}; do | |
MASTER_STATUS=$(curl -s http://localhost:8081/healthz | jq -r .status) | |
SLAVE_STATUS=$(curl -s http://localhost:8082/healthz | jq -r .status) | |
if [ "$MASTER_STATUS" == "SERVING" ] && [ "$SLAVE_STATUS" == "SERVING" ]; then | |
echo "Service is healthy!" | |
exit 0 | |
fi | |
echo "Waiting for the service to be healthy..." | |
sleep 5 | |
done | |
echo "Service did not become healthy in time." | |
exit 1 | |
- name: "Run runn" | |
run: | | |
export MASTER_ENDPOINT=http://0.0.0.0:8081 | |
export SLAVE_ENDPOINT=http://0.0.0.0:8082 | |
make api-test-master-slave |