89 lines
2.5 KiB
Bash
Executable File
89 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# test_docker_compose.sh - Verify docker-compose.yml matches spec for task-12
|
|
# RED: Run before docker-compose.yml exists (should fail)
|
|
# GREEN: Run after docker-compose.yml is created (should pass)
|
|
|
|
REPO=/home/ken/workspace/research-workbench
|
|
COMPOSE="$REPO/docker-compose.yml"
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
check_file() {
|
|
if [ -f "$1" ]; then
|
|
echo "PASS: file '$1' exists"
|
|
((PASS++))
|
|
else
|
|
echo "FAIL: file '$1' should exist but is missing"
|
|
((FAIL++))
|
|
fi
|
|
}
|
|
|
|
check_contains() {
|
|
local pattern="$1"
|
|
local label="$2"
|
|
if grep -qF -- "$pattern" "$COMPOSE" 2>/dev/null; then
|
|
echo "PASS: docker-compose.yml contains $label"
|
|
((PASS++))
|
|
else
|
|
echo "FAIL: docker-compose.yml missing $label"
|
|
((FAIL++))
|
|
fi
|
|
}
|
|
|
|
check_regex() {
|
|
local pattern="$1"
|
|
local label="$2"
|
|
if grep -qE "$pattern" "$COMPOSE" 2>/dev/null; then
|
|
echo "PASS: docker-compose.yml contains $label"
|
|
((PASS++))
|
|
else
|
|
echo "FAIL: docker-compose.yml missing $label"
|
|
((FAIL++))
|
|
fi
|
|
}
|
|
|
|
echo "=== Checking docker-compose.yml exists ==="
|
|
check_file "$COMPOSE"
|
|
|
|
echo ""
|
|
echo "=== Checking prerequisite comments ==="
|
|
check_contains "npm run build" "frontend build prerequisite comment"
|
|
check_contains "ANTHROPIC_API_KEY" "ANTHROPIC_API_KEY prerequisite comment"
|
|
check_contains "bcrypt" "bcrypt password hash prerequisite comment"
|
|
|
|
echo ""
|
|
echo "=== Checking services ==="
|
|
check_contains "services:" "services section"
|
|
check_contains "workbench:" "workbench service"
|
|
|
|
echo ""
|
|
echo "=== Checking build ==="
|
|
check_regex "build: \." "build: ."
|
|
|
|
echo ""
|
|
echo "=== Checking ports ==="
|
|
check_contains "8080:8080" "port 8080:8080 (Web UI)"
|
|
check_contains "6080:6080" "port 6080:6080 (noVNC browser view)"
|
|
|
|
echo ""
|
|
echo "=== Checking environment variables ==="
|
|
check_regex "ANTHROPIC_API_KEY=\\\$\{ANTHROPIC_API_KEY\}" "ANTHROPIC_API_KEY env var"
|
|
check_regex "AUTH_USER=\\\$\{AUTH_USER:-admin@localhost\}" "AUTH_USER env var with default"
|
|
check_regex "AUTH_PASS_HASH=\\\$\{AUTH_PASS_HASH\}" "AUTH_PASS_HASH env var"
|
|
check_contains "DISPLAY=:99" "DISPLAY=:99 env var"
|
|
|
|
echo ""
|
|
echo "=== Checking volumes ==="
|
|
check_contains "./artifacts:/app/artifacts" "artifacts volume"
|
|
|
|
echo ""
|
|
echo "=== Checking restart policy ==="
|
|
check_contains "restart: unless-stopped" "restart unless-stopped"
|
|
|
|
echo ""
|
|
echo "=============================="
|
|
echo "Results: $PASS passed, $FAIL failed"
|
|
echo "=============================="
|
|
|
|
[ $FAIL -eq 0 ] && exit 0 || exit 1
|