Skip to content

Commit 9283229

Browse files
committed
fix(test-setup): improve service synchronization and reliability
- Extend Docker health check timeouts from 30s to 120s - Add HTTP endpoint verification for indexer-service and tap-agent - Override allocation ID with known test value for consistency - Add 10s wait for indexer chain synchronization - Add optional pgAdmin startup for debugging
1 parent 72e9760 commit 9283229

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

pg_admin.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
DATABASE_URL=postgresql://postgres@localhost:5432/indexer_components_1
4+
5+
echo "Starting pgAdmin4 in Docker..."
6+
echo "Database URL: $DATABASE_URL"
7+
echo ""
8+
9+
# Get the Docker network name for local-network-semiotic
10+
NETWORK_NAME="local-network-semiotic_default"
11+
12+
# Check if the network exists
13+
if ! docker network ls | grep -q "$NETWORK_NAME"; then
14+
echo "Warning: Docker network '$NETWORK_NAME' not found."
15+
echo "Make sure your local-network-semiotic compose stack is running first."
16+
echo "Run: cd local-network-semiotic && docker-compose up -d postgres"
17+
echo ""
18+
fi
19+
20+
# Run pgAdmin in Docker, connected to the same network as PostgreSQL
21+
docker run -p 8080:80 \
22+
--name pgadmin4 \
23+
24+
-e PGADMIN_DEFAULT_PASSWORD=admin \
25+
-d dpage/pgadmin4
26+
27+
echo ""
28+
echo "pgAdmin4 is starting up..."
29+
echo "Once ready, access it at: http://localhost:8080/login"
30+
echo ""
31+
echo "Login credentials:"
32+
echo " Email: [email protected]"
33+
echo " Password: admin"
34+
echo ""
35+
echo "Database connection details:"
36+
echo " Host name/address: 172.17.0.1"
37+
echo " Port: 5432"
38+
echo " Database: postgres (or specific database name)"
39+
echo " Username: postgres"
40+
echo " Password: (leave empty - auth method is 'trust')"
41+
echo ""
42+
echo "Note: Use 'postgres' as the host since both containers are in the same Docker network"
43+
echo ""
44+
echo "To stop pgAdmin: docker stop pgadmin4 && docker rm pgadmin4"

setup-test-network.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ fund_escrow() {
7777
GRAPH_TOKEN=$(jq -r '."1337".L2GraphToken.address' local-network/horizon.json)
7878
TAP_ESCROW=$(jq -r '."1337".Escrow' local-network/tap-contracts.json)
7979

80+
# Override with test values taken from test-assets/src/lib.rs
81+
ALLOCATION_ID="0xfa44c72b753a66591f241c7dc04e8178c30e13af" # ALLOCATION_ID_0
82+
8083
if [ -z "$GRAPH_TOKEN" ] || [ -z "$TAP_ESCROW" ] || [ "$GRAPH_TOKEN" == "null" ] || [ "$TAP_ESCROW" == "null" ]; then
8184
echo "Error: Could not read contract addresses from horizon.json or tap-contracts.json"
8285
echo "GRAPH_TOKEN: $GRAPH_TOKEN"
@@ -252,8 +255,23 @@ fi
252255
docker compose -f docker-compose.yml -f docker-compose.override.yml up --build -d
253256
rm docker-compose.override.yml
254257

255-
timeout 30 bash -c 'until docker ps | grep indexer | grep -q healthy; do sleep 5; done'
256-
timeout 30 bash -c 'until docker ps | grep tap-agent | grep -q healthy; do sleep 5; done'
258+
# Wait for indexer-service and tap-agent to be healthy with better timeouts
259+
echo "Waiting for indexer-service to be healthy..."
260+
timeout 120 bash -c 'until docker ps | grep indexer-service | grep -q healthy; do echo "Still waiting for indexer-service..."; sleep 5; done'
261+
262+
echo "Waiting for tap-agent to be healthy..."
263+
timeout 120 bash -c 'until docker ps | grep tap-agent | grep -q healthy; do echo "Still waiting for tap-agent..."; sleep 5; done'
264+
265+
# Additional check to ensure services are responding
266+
echo "Verifying indexer-service is responding..."
267+
timeout 60 bash -c 'until curl -f http://localhost:7601/health > /dev/null 2>&1; do echo "Waiting for indexer-service health endpoint..."; sleep 3; done'
268+
269+
echo "Verifying tap-agent is responding..."
270+
timeout 60 bash -c 'until curl -f http://localhost:7300/metrics > /dev/null 2>&1; do echo "Waiting for tap-agent metrics endpoint..."; sleep 3; done'
271+
272+
# Wait for indexer to sync with chain before starting gateway
273+
echo "Checking chain and indexer synchronization..."
274+
sleep 10 # Give indexer time to process initial blocks
257275

258276
echo "Building gateway image..."
259277
source local-network/.env
@@ -275,6 +293,7 @@ if [ ! -f "local-network/subgraph-service.json" ]; then
275293
fi
276294

277295
# Updated to use the horizon file structure and include tap-contracts.json
296+
# Gateway now generates config with increased max_lag_seconds in gateway/run.sh
278297
docker run -d --name gateway \
279298
--network local-network_default \
280299
-p 7700:7700 \
@@ -324,3 +343,9 @@ echo "Images size: $END_IMAGES_SIZE"
324343
echo "Containers size: $END_CONTAINERS_SIZE"
325344
echo "Volumes size: $END_VOLUMES_SIZE"
326345
echo "==========================================="
346+
347+
# Optional: Start pgAdmin for database inspection
348+
if [ "$START_PGADMIN" = "true" ]; then
349+
echo "Starting pgAdmin for database inspection..."
350+
./pg_admin.sh
351+
fi

0 commit comments

Comments
 (0)