Skip to content

Commit a55f053

Browse files
committed
fix: enforce docker install for tests
Ensure test scripts invoke install-docker.sh when required. Document docker-based validator and challenge tests.
1 parent 65b0b82 commit a55f053

6 files changed

Lines changed: 34 additions & 18 deletions

File tree

‎docs/challenge-integration.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ Platform uses a modular challenge architecture where each challenge:
3333
└─────────────┘ └─────────────┘ └─────────────┘
3434
```
3535

36+
## Testing With Docker
37+
38+
Challenge containers are exercised by the validator test harness. Use `./scripts/test-comprehensive.sh` to run Docker-backed integration tests; it will call `scripts/install-docker.sh` if Docker or Compose are missing (unless `PLATFORM_TEST_DOCKER_MODE=skip`).
39+
40+
---
41+
3642
## Creating a Challenge Crate
3743

3844
### 1. Project Structure

‎docs/validator.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ cd platform
2222
cp .env.example .env
2323
# Edit .env: add your VALIDATOR_SECRET_KEY (BIP39 mnemonic)
2424

25+
# Optional: install Docker + Compose (used by test scripts)
26+
./scripts/install-docker.sh
27+
2528
# Create the Docker network (required, one-time setup)
2629
docker network create platform-network
2730

@@ -55,6 +58,7 @@ The validator will auto-connect to the network and sync. No GPUs, no third-party
5558
- Docker 24.0+
5659
- Docker Compose v2
5760
- Linux (Ubuntu 22.04+ recommended)
61+
- `scripts/install-docker.sh` (automated installer used by test scripts)
5862

5963
### Bittensor
6064

@@ -192,6 +196,15 @@ Expected response:
192196

193197
---
194198

199+
## Testing and Validation
200+
201+
Validator deployment tests rely on Docker and Docker Compose. The test harness automatically invokes `scripts/install-docker.sh` when Docker is missing (unless `PLATFORM_TEST_DOCKER_MODE=skip`).
202+
203+
- Run `./scripts/test-comprehensive.sh` to execute Docker-backed integration and multi-validator tests.
204+
- Run `./scripts/test-all.sh` for build/unit-only runs (Docker not required).
205+
206+
---
207+
195208
## Troubleshooting
196209

197210
### Connection Issues

‎scripts/test-comprehensive.sh‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ else
4747
log_failure "Unit tests failed"
4848
fi
4949

50-
log_info "============================================================================="
51-
log_info "Phase 3: Docker Integration Tests"
52-
log_info "============================================================================="
53-
if platform_should_run_docker; then
54-
if platform_require_compose; then
55-
platform_ensure_network
56-
platform_install_docker_if_needed
5750
log_info "============================================================================="
5851
log_info "Phase 3: Docker Integration Tests"
5952
log_info "============================================================================="
@@ -143,13 +136,6 @@ else
143136
log_failure "Distributed storage tests failed"
144137
fi
145138

146-
log_info "============================================================================="
147-
log_info "Phase 8: Multi-validator Docker Compose"
148-
log_info "============================================================================="
149-
if platform_should_run_docker; then
150-
if platform_require_compose; then
151-
platform_ensure_network
152-
platform_install_docker_if_needed
153139
log_info "============================================================================="
154140
log_info "Phase 8: Multi-validator Docker Compose"
155141
log_info "============================================================================="

‎scripts/test-harness.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ platform_install_docker_if_needed() {
117117

118118
local script_dir
119119
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
120+
if [ ! -x "${script_dir}/install-docker.sh" ]; then
121+
log_failure "scripts/install-docker.sh not found or not executable"
122+
return 1
123+
fi
124+
120125
log_info "Docker/Compose missing; attempting installation via scripts/install-docker.sh"
121126
"${script_dir}/install-docker.sh"
122127

‎tests/docker/entrypoint-test.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ fi
2020
ARGS="--data-dir ${DATA_DIR:-/data}"
2121
ARGS="$ARGS --listen-addr ${P2P_LISTEN_ADDR:-/ip4/0.0.0.0/tcp/9000}"
2222

23+
if [ "${PLATFORM_TEST_DOCKER_MODE:-auto}" = "required" ] && command -v platform_install_docker_if_needed >/dev/null 2>&1; then
24+
platform_install_docker_if_needed
25+
fi
26+
2327
if [ -n "${VALIDATOR_SECRET_KEY:-}" ]; then
2428
ARGS="$ARGS --secret-key ${VALIDATOR_SECRET_KEY}"
2529
fi

‎tests/docker/test-multi-validator.sh‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# =============================================================================
55
# Tests multiple validators in a P2P network without Docker build issues
66
# Uses locally built binary
7-
# Note: This script does not require Docker; see scripts/test-comprehensive.sh
7+
# Note: This script does not require Docker; see scripts/test-comprehensive.sh for Docker-based suites
88
# =============================================================================
99

1010
set -euo pipefail
@@ -13,14 +13,16 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1313
# shellcheck source=../../scripts/test-harness.sh
1414
source "${SCRIPT_DIR}/../../scripts/test-harness.sh"
1515

16-
platform_test_init
17-
trap platform_cleanup_run_dir EXIT
1816
platform_test_init
1917
trap platform_cleanup_run_dir EXIT
2018

21-
VALIDATOR_BINARY="${VALIDATOR_BINARY:-${PLATFORM_TEST_ROOT}/target/release/validator-node}"
19+
if [ "${PLATFORM_TEST_DOCKER_MODE:-auto}" = "required" ]; then
20+
platform_install_docker_if_needed
21+
fi
22+
2223
NUM_VALIDATORS="${NUM_VALIDATORS:-3}"
2324
BASE_PORT="${BASE_PORT:-9100}"
25+
VALIDATOR_BINARY="${VALIDATOR_BINARY:-${PLATFORM_TEST_ROOT}/target/release/validator-node}"
2426
PLATFORM_TEST_RUN_DIR="${PLATFORM_TEST_RUN_DIR:-${PLATFORM_TEST_TMP_BASE}/multi-validator}"
2527

2628
log_info "Test directory: ${PLATFORM_TEST_RUN_DIR}"

0 commit comments

Comments
 (0)