|
1 | 1 | #!/bin/bash |
2 | | -# Zond Docker Integration Test Runner |
| 2 | +# Zond Phase 1: Topological Integration Test Runner |
3 | 3 | # |
4 | | -# This script builds the Zond binaries, brings up the Docker Compose environment, |
5 | | -# and executes the integration scanner to verify network-wide discovery. |
| 4 | +# Verifies Multi-NIC discovery, DNS resolution, and Routed segment discovery. |
6 | 5 |
|
7 | 6 | set -e |
8 | 7 |
|
9 | | -# 1. Build the project to ensure we have fresh binaries |
10 | | -echo ">>> Building Zond binaries..." |
11 | | -cargo build |
| 8 | +# 1. Note: Build is now handled inside the scanner.Dockerfile multi-stage build. |
| 9 | +echo ">>> (Build handled by Docker Compose)" |
| 10 | +# cargo build is no longer necessary on host |
12 | 11 |
|
13 | | -# 2. Build and start the Docker environment |
| 12 | +# 2. Start the environment |
14 | 13 | echo ">>> Bringing up Docker nodes..." |
15 | | -docker-compose -f docker-compose.test.yml up --build -d |
| 14 | +docker compose -f docker-compose.test.yml up --build -d |
16 | 15 |
|
17 | | -# Give containers a second to start listeners |
18 | | -sleep 2 |
| 16 | +# Give containers a second to start |
| 17 | +sleep 3 |
19 | 18 |
|
20 | | -# 3. Perform a discovery scan from the scanner node |
21 | | -echo ">>> Executing Zond discovery scan from scanner node..." |
22 | | -docker exec zond-integration-scanner ./target/debug/zond discover 172.20.0.0/24 172.30.0.0/24 |
| 19 | +# 3. Setup Routes for Discovery |
| 20 | +# We need to tell the scanner how to reach the isolated network (172.30.0.0/24) via the gateway |
| 21 | +# We search all networks for the one in the 172.20.0.0/24 subnet |
| 22 | +echo ">>> Extracting gateway IP..." |
| 23 | +for i in {1..5}; do |
| 24 | + GATEWAY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' zond-gateway | tr ' ' '\n' | grep '172.20.' | head -n 1) |
| 25 | + if [ ! -z "$GATEWAY_IP" ]; then |
| 26 | + break |
| 27 | + fi |
| 28 | + echo "Wait for gateway IP... ($i/5)" |
| 29 | + sleep 2 |
| 30 | +done |
23 | 31 |
|
24 | | -# 4. Cleanup |
| 32 | +if [ -z "$GATEWAY_IP" ]; then |
| 33 | + echo "Error: Could not find gateway IP on LAN network." |
| 34 | + docker compose -f docker-compose.test.yml down |
| 35 | + exit 1 |
| 36 | +fi |
| 37 | + |
| 38 | +echo ">>> Setting up static route to isolated network via gateway at $GATEWAY_IP..." |
| 39 | +docker exec zond-integration-scanner ip route add 172.30.0.0/24 via $GATEWAY_IP |
| 40 | + |
| 41 | +# 4. Perform Phase 1 Tests |
| 42 | +echo ">>> [Phase 1] Executing Topological Discovery Scan..." |
| 43 | + |
| 44 | +# Scan all three target subnets |
| 45 | +# - 172.20.0.0/24 (LAN 1) |
| 46 | +# - 172.25.0.0/24 (LAN 2 - Extra NIC) |
| 47 | +# - 172.30.0.0/24 (Routed Isolated) |
| 48 | +# We turn on trace logging to see what's happening |
| 49 | +EXIT_CODE=0 |
| 50 | +docker exec zond-integration-scanner ./zond -vvv discover 172.20.0.0/24 172.25.0.0/24 172.30.0.0/24 || EXIT_CODE=$? |
| 51 | + |
| 52 | +if [ $EXIT_CODE -ne 0 ]; then |
| 53 | + echo ">>> Scan failed with exit code $EXIT_CODE. Container logs:" |
| 54 | + docker logs zond-integration-scanner |
| 55 | +fi |
| 56 | + |
| 57 | +# 5. Cleanup |
25 | 58 | echo ">>> Tearing down Docker nodes..." |
26 | | -docker-compose -f docker-compose.test.yml down |
| 59 | +docker compose -f docker-compose.test.yml down |
27 | 60 |
|
28 | | -echo ">>> Docker Integration tests completed successfully." |
| 61 | +exit $EXIT_CODE |
0 commit comments