Skip to content

Commit

Permalink
Enhance docker compose liveness test
Browse files Browse the repository at this point in the history
  • Loading branch information
Fly-Style committed Nov 25, 2024
1 parent 6719a49 commit 822ae74
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 12 deletions.
84 changes: 81 additions & 3 deletions .github/workflows/compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

jobs:
run-docker-compose:
run-docker-compose-default-indexer:
runs-on: ubuntu-latest

steps:
Expand All @@ -22,6 +22,16 @@ jobs:
sudo apt-get update
sudo apt-get install docker-compose -y
- name: Build FastNear indexer container
uses: docker/build-push-action@v5
with:
load: true
context: .
file: ./indexer/FastIndexer.dockerfile
tags: nffl-fast-indexer
cache-from: type=gha,scope=indexer
cache-to: type=gha,mode=max,scope=indexer

- name: Build indexer container
uses: docker/build-push-action@v5
with:
Expand Down Expand Up @@ -65,8 +75,8 @@ jobs:
- name: Build and start Docker Compose services
run: docker-compose --profile default-indexer -f ./docker-compose.yml up --build -d

- name: Wait for 5 minutes
run: sleep 300
- name: Wait for ~3 minutes
run: sleep 200

- name: List running containers
run: |
Expand Down Expand Up @@ -126,3 +136,71 @@ jobs:
- name: Tear down Docker Compose services
run: docker-compose --profile default-indexer -f ./docker-compose.yml down

- name: Wait for 15 seconds
run: sleep 15

- name: Build and start Docker Compose services with FastNear indexer
run: docker-compose --profile fast-indexer -f ./docker-compose.yml up --build -d

- name: Wait for 2 minutes
run: sleep 120

- name: List running containers
run: |
echo "Running containers:"
docker ps --format "{{.Names}}"
- name: Ensure containers are running
run: |
containers=(
"nffl_operator1-health_1"
"nffl-operator1"
"nffl_operator0-health_1"
"nffl-operator0"
"rollup1-relayer"
"rollup0-relayer"
"nffl-fast-indexer"
"nffl-aggregator"
"nffl_agreator-health_1"
"mainnet-anvil"
"prometheus"
"rollup0-anvil"
"rmq"
"rollup1-anvil"
"grafana"
) # List of container names
for container in "${containers[@]}"; do
if docker inspect -f '{{.State.Running}}' "$container" >/dev/null 2>&1; then
echo "$container is running"
else
echo "$container is not running"
exit 1
fi
done
- name: Check health status
run: |
services=(
"nffl_operator1-health_1"
"nffl_operator0-health_1"
"nffl_agreator-health_1"
"rollup1-anvil"
"rollup0-anvil"
"mainnet-anvil"
"rmq"
) # List of services names
for service in "${services[@]}"; do
status=$(docker inspect -f '{{.State.Health.Status}}' $service)
if [ "$status" != "healthy" ]; then
echo "Service $service is not healthy"
docker-compose -f ./docker-compose.yml logs $service
exit 1
else
echo "Service $service is healthy"
fi
done
- name: Tear down Docker Compose services
run: docker-compose --profile fast-indexer -f ./docker-compose.yml down
19 changes: 10 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: "3"

networks:
nffl:
name: nffl
driver: bridge

services:
Expand Down Expand Up @@ -139,10 +138,10 @@ services:
networks:
- nffl

indexer:
image: nffl-indexer:latest
container_name: nffl-indexer
profiles: ["default-indexer"]
fastnear-indexer:
image: nffl-fast-indexer:latest
container_name: nffl-fast-indexer
profiles: ["fast-indexer"]
depends_on:
rmq:
condition: service_healthy
Expand Down Expand Up @@ -173,10 +172,10 @@ services:
networks:
- nffl

fastnear-indexer:
image: nffl-fast-indexer:latest
container_name: nffl-fast-indexer
profiles: ["fast-indexer"]
indexer:
image: nffl-indexer:latest
container_name: nffl-indexer
profiles: ["default-indexer"]
depends_on:
rmq:
condition: service_healthy
Expand Down Expand Up @@ -210,6 +209,7 @@ services:
indexer-setup:
image: debian:bookworm
container_name: nffl-indexer-setup
profiles: ["default-indexer"]
volumes:
- near_cli_data:/near-cli
- near_cli_keys:/root/.near-credentials
Expand All @@ -225,6 +225,7 @@ services:
near-da-deploy:
image: node:16
container_name: nffl-near-da-deploy
profiles: ["default-indexer"]
depends_on:
indexer:
condition: service_healthy
Expand Down

0 comments on commit 822ae74

Please sign in to comment.