Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: add sequencer health check
Browse files Browse the repository at this point in the history
Signed-off-by: Jawad Tariq <[email protected]>
  • Loading branch information
JDawg287 committed Dec 14, 2023
1 parent dfd9f61 commit 21ced39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions subnet-incal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,18 @@ services:
condition: service_healthy
entrypoint: ""
command: bash -c "
apt-get update && apt-get install -y net-tools &&
source /contracts/.env &&
cp -vr /data/data-1/consensus /tmp/node_config/node/sequencer-incal/consensus &&
cp -vr /data/data-1/libp2p /tmp/node_config/node/sequencer-incal/libp2p &&
mkdir -p /tmp/node_config/subnet/incal/ &&
cp -v /data/genesis.json /tmp/node_config/subnet/incal/genesis.json &&
echo Topos core contract address=$(printenv TOPOS_CORE_PROXY_CONTRACT_ADDRESS), set manually in config &&
topos node up --name sequencer-incal --home /tmp/node_config --no-edge-process"
healthcheck:
test: ["CMD-SHELL", "test $(netstat -ntu | grep ':8545' | wc -l) -gt 0"]
interval: 1s
retries: 10
environment:
- RUST_LOG=info,topos=debug
- TOOLCHAIN_VERSION=stable
Expand Down
5 changes: 5 additions & 0 deletions subnet-topos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,18 @@ services:
condition: service_completed_successfully
entrypoint: ""
command: bash -c "
apt-get update && apt-get install -y net-tools &&
source /contracts/.env &&
mkdir -p /data/node/sequencer-topos/consensus -p /data/node/sequencer-topos/libp2p -p /data/subnet/topos-sequencer/ &&
cp -vr /data/node/node-1/consensus /data/node/sequencer-topos/ &&
cp -vr /data/node/node-1/libp2p /data/node/sequencer-topos/ &&
cp -vr /data/subnet/topos/genesis.json /data/subnet/topos-sequencer/genesis.json &&
echo \"Topos Core contract address:\" $(printenv TOPOS_CORE_PROXY_CONTRACT_ADDRESS), set manually in config &&
topos node up --name sequencer-topos --home /data/ --no-edge-process"
healthcheck:
test: ["CMD-SHELL", "test $(netstat -ntu | grep ':8545' | wc -l) -gt 0"]
interval: 1s
retries: 10
environment:
- RUST_LOG=info,topos=debug
- TOOLCHAIN_VERSION=stable
Expand Down
11 changes: 3 additions & 8 deletions tests/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ stop_network () {

check_network_health () {
# Check if all relevant containers are healthy
# TODO: Add healcheck for sequencers, currenly only tce and polygon edge nodes are checked
SERVICE_NAMES=$(docker compose config --dry-run --services | grep -e node)
SERVICE_NAMES=$(docker compose config --dry-run --services | grep -e node -e sequencer)
EXPECTED=$(docker compose ps -aq $SERVICE_NAMES | wc -l)
COUNT=$(docker inspect --format "{{.State.Health.Status }}" $(docker compose ps -aq $SERVICE_NAMES) | grep "^healthy$"|wc -l)
echo "Number of Healthy containers: $COUNT"
if [[ $COUNT -eq $EXPECTED ]]; then
echo "All expected containers healthy"
return 0
echo 0
else
echo "Unhealthy containers"
docker compose -f tools/docker-compose.yml ps -a peer boot
return 1
echo 1
fi
}

Expand Down

0 comments on commit 21ced39

Please sign in to comment.