Skip to content

Commit fa1a1e9

Browse files
committed
Add a CI test
1 parent 73f2c90 commit fa1a1e9

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: API BN Recovery Test
2+
3+
on:
4+
workflow_dispatch: # manual trigger for testing
5+
schedule:
6+
- cron: '0 6 * * 1' # weekly on Monday at 06:00 UTC
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
test:
13+
name: API BN Recovery Smoke Test
14+
runs-on:
15+
labels: dind-large
16+
container:
17+
image: ghcr.io/dfinity/ic-build@sha256:2caf6df6009b29ede72a520b60f3db064324e22192be532349caa82a987f8c50
18+
options: >-
19+
-e NODE_NAME --privileged --cgroupns host
20+
--mount type=tmpfs,target="/home/buildifier/.local/share/containers"
21+
timeout-minutes: 10
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Build binaries with Bazel
27+
uses: ./.github/actions/bazel
28+
with:
29+
run: |
30+
bazel build \
31+
//rs/boundary_node/ic_boundary:ic-boundary \
32+
//rs/orchestrator/registry_replicator:ic-registry-replicator
33+
34+
- name: Install dfx
35+
run: |
36+
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
37+
echo "$HOME/.local/share/dfx/bin" >> "$GITHUB_PATH"
38+
39+
- name: Run smoke test
40+
run: ./ic-os/api-bn-recovery/test.sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build.sh
2+
test.sh
23
.dockerignore
34
*.md

ic-os/api-bn-recovery/test.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
# CI smoke test for the API Boundary Node recovery container.
3+
# Builds the image, starts it, waits for readiness, and verifies
4+
# that a canister query through it succeeds.
5+
set -euo pipefail
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
CONTAINER_NAME="api-bn-test-$$"
9+
IMAGE_NAME="api-boundary-node"
10+
IMAGE_TAG="test"
11+
MAX_WAIT=300 # 5 minutes for registry sync + replica discovery
12+
13+
cleanup() {
14+
echo "Cleaning up..."
15+
docker rm -f "$CONTAINER_NAME" 2>/dev/null || true
16+
}
17+
trap cleanup EXIT
18+
19+
# ─── Pre-check: stop anything already on port 8080 ───
20+
if curl -sf http://localhost:8080/api/v2/status -o /dev/null 2>/dev/null; then
21+
echo "ERROR: Something is already listening on port 8080."
22+
echo "Stop any existing api-bn containers first: docker rm -f api-bn"
23+
exit 1
24+
fi
25+
26+
# ─── Build ───
27+
echo "=== Building image ==="
28+
IMAGE_NAME="$IMAGE_NAME" IMAGE_TAG="$IMAGE_TAG" "${SCRIPT_DIR}/build.sh"
29+
30+
# ─── Run ───
31+
echo "=== Starting container ==="
32+
docker run -d --name "$CONTAINER_NAME" --network host "${IMAGE_NAME}:${IMAGE_TAG}"
33+
34+
# ─── Wait for readiness ───
35+
echo "=== Waiting for boundary node to become ready (up to ${MAX_WAIT}s) ==="
36+
WAITED=0
37+
while true; do
38+
# Check container is still running
39+
if ! docker inspect --format='{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q true; then
40+
echo "FAIL: Container exited unexpectedly."
41+
docker logs "$CONTAINER_NAME" 2>&1 | tail -30
42+
exit 1
43+
fi
44+
45+
# Check if the boundary node is healthy via the Prometheus metric
46+
if curl -sf http://localhost:9090/metrics 2>/dev/null | grep -q 'ic_boundary_healthy 1'; then
47+
echo "Boundary node is healthy after ${WAITED}s."
48+
break
49+
fi
50+
51+
if [ "$WAITED" -ge "$MAX_WAIT" ]; then
52+
echo "FAIL: Boundary node did not become healthy within ${MAX_WAIT}s."
53+
docker logs "$CONTAINER_NAME" 2>&1 | tail -30
54+
exit 1
55+
fi
56+
57+
sleep 5
58+
WAITED=$((WAITED + 5))
59+
if [ $((WAITED % 30)) -eq 0 ]; then
60+
echo " Still waiting... (${WAITED}s)"
61+
fi
62+
done
63+
64+
# ─── Test canister query ───
65+
echo "=== Testing canister query ==="
66+
RESULT=$(dfx canister --network http://localhost:8080 call ryjl3-tyaaa-aaaaa-aaaba-cai name --query 2>&1)
67+
68+
if echo "$RESULT" | grep -q "Internet Computer"; then
69+
echo "PASS: $RESULT"
70+
exit 0
71+
else
72+
echo "FAIL: Unexpected response: $RESULT"
73+
exit 1
74+
fi

0 commit comments

Comments
 (0)