Files
rmyndharis--openwa/scripts/smoke-test-docker-proxy.sh
wehub-resource-sync 4ce4204b6c
CI / Lint (push) Failing after 2s
CI / Build (push) Has been skipped
SDK CI / PHP SDK (push) Failing after 1s
Split PHP SDK / PHP SDK tests (push) Failing after 1s
CI / Test (push) Failing after 1s
CI / Dashboard (push) Failing after 0s
SDK CI / JavaScript SDK (push) Failing after 0s
SDK CI / Python SDK (push) Failing after 2s
SDK CI / Java SDK (push) Failing after 1s
Split PHP SDK / Mirror sdk/php -> rmyndharis/openwa-php (push) Has been skipped
CI / Test (PostgreSQL migrations) (push) Failing after 7m47s
CI / Docker Build (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:24:08 +08:00

54 lines
1.8 KiB
Bash

#!/bin/sh
# Smoke test: verify openwa-api can list containers via docker-socket-proxy.
# Run this after `docker compose up -d` with the stack fully started.
# Usage: ./scripts/smoke-test-docker-proxy.sh [API_KEY]
set -e
API_KEY="${1:-}"
BASE_URL="${BASE_URL:-http://localhost:2785}"
if [ -z "$API_KEY" ]; then
echo "Usage: $0 <admin-api-key>" >&2
exit 1
fi
echo "==> Checking openwa-api health..."
STATUS=$(curl -sf -o /dev/null -w "%{http_code}" "$BASE_URL/api/health")
if [ "$STATUS" != "200" ]; then
echo "FAIL: /api/health returned HTTP $STATUS (expected 200)" >&2
exit 1
fi
echo "PASS: API health OK"
echo ""
echo "==> Verifying Docker proxy connectivity via infrastructure status..."
RESPONSE=$(curl -sf \
-H "X-API-Key: $API_KEY" \
"$BASE_URL/api/infra/status")
echo "Response: $RESPONSE"
# The key check: docker availability flag from DockerService.isDockerAvailable()
# If the proxy is unreachable, the service logs a warning and sets isAvailable=false.
# We indirectly validate this by confirming the API responds without error.
echo ""
echo "==> Verifying docker-proxy container is running..."
PROXY_STATE=$(docker inspect --format='{{.State.Status}}' openwa-docker-proxy 2>/dev/null || echo "not_found")
if [ "$PROXY_STATE" != "running" ]; then
echo "FAIL: openwa-docker-proxy is not running (state: $PROXY_STATE)" >&2
exit 1
fi
echo "PASS: openwa-docker-proxy is running"
echo ""
echo "==> Verifying openwa-api socket mount is gone..."
SOCKET_MOUNT=$(docker inspect openwa-api --format='{{range .Mounts}}{{.Source}}{{"\n"}}{{end}}' 2>/dev/null | grep "docker.sock" || true)
if [ -n "$SOCKET_MOUNT" ]; then
echo "FAIL: openwa-api still has a docker.sock mount: $SOCKET_MOUNT" >&2
exit 1
fi
echo "PASS: openwa-api has no direct docker.sock mount"
echo ""
echo "All smoke tests passed!"