Each server runs an ultralight probe (scratch image, ~7 MiB RSS) that tails the logs, ships raw lines to the hub over HTTPS with an on-disk spool, and applies enforce decisions locally. The hub keeps one node per probe (primary node = the 1.x data dir, unchanged), does all analysis and serves the UI. Peer federation is removed. 'urutau import' brings 1.x data dirs in with hash and count verification. UI: probes page, host qualified incidents, IPs never wrap, egress heatmap labels, live and replay globes no longer auto-rotate, replay repeat, live traffic metrics. BREAKING CHANGE: URUTAU_PEERS, URUTAU_PEER_* and /api/v1/peer/* are gone; log path variables move from the hub to the probe. See docs/migration-2.0.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
3.6 KiB
Bash
Executable File
59 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Smoke-tests an Urutau hub image: the HEALTHCHECK command works, the API is
|
|
# closed without a token and open with it, the removed 1.x federation routes
|
|
# answer 404 and the removed variables stop the start, the dashboard is served,
|
|
# urutau doctor reports a version, the daemon is not root and SIGTERM stops it
|
|
# cleanly with exit 0. (The probe image has its own script: smoke-probe.sh.)
|
|
# The image has no curl: HTTP checks use the BusyBox wget that Alpine ships.
|
|
# Everything runs through `docker exec`, so no port has to be reachable from the
|
|
# CI job container. The container is always removed.
|
|
#
|
|
# scripts/smoke-image.sh <image-ref>
|
|
set -euo pipefail
|
|
|
|
image=${1:?usage: smoke-image.sh <image-ref>}
|
|
name="urutau-smoke-$$-$RANDOM"
|
|
token=$(head -c 40 /dev/urandom | base64 | tr -d '=+/\n')
|
|
trap 'docker rm -f "$name" >/dev/null 2>&1 || true' EXIT
|
|
fail() { echo "smoke: $*" >&2; docker logs "$name" >&2 2>&1 || true; exit 1; }
|
|
base=http://127.0.0.1:8790
|
|
# status <url> [header]: HTTP status code of a GET (wget -S prints the response headers)
|
|
status() {
|
|
local url=$1; shift
|
|
docker exec "$name" wget -S -q -O /dev/null "$@" "$url" 2>&1 | awk '/^ *HTTP\//{c=$2} END{print c}'
|
|
}
|
|
get() { local url=$1; shift; docker exec "$name" wget -q -O - "$@" "$url"; }
|
|
|
|
# No log files are mounted: the sources wait for them. docker create + start
|
|
# instead of a bind mount, which the daemon may not see from a CI job.
|
|
docker create --name "$name" -e URUTAU_TOKEN="$token" -e URUTAU_GEO_UPDATE=0 "$image" >/dev/null
|
|
docker start "$name" >/dev/null
|
|
for _ in $(seq 1 30); do
|
|
docker exec "$name" urutau healthcheck >/dev/null 2>&1 && break
|
|
sleep 1
|
|
done
|
|
docker exec "$name" urutau healthcheck || fail "urutau healthcheck failed"
|
|
out=$(get "$base/api/health") || fail "/api/health did not answer"
|
|
grep -q '"status":"ok"' <<<"$out" || fail "/api/health is not ok"
|
|
grep -q '"version"' <<<"$out" && fail "/api/health must not expose the version"
|
|
[ "$(status "$base/api/v1/summary")" = 401 ] || fail "/api/v1/summary without a token must answer 401"
|
|
out=$(get "$base/api/v1/summary" --header "Authorization: Bearer $token") || fail "authenticated summary failed"
|
|
grep -q '"totals"' <<<"$out" || fail "summary has no totals"
|
|
[ "$(status "$base/api/v1/peer/export" --header "Authorization: Bearer $token")" = 404 ] || fail "the 1.x peer export must be gone (404)"
|
|
out=$(get "$base/login") || fail "login page did not answer"
|
|
grep -qi '<!doctype html' <<<"$out" || fail "login page is not served"
|
|
out=$(get "$base/" --header "Authorization: Bearer $token") || fail "dashboard did not answer"
|
|
grep -qi '<!doctype html' <<<"$out" || fail "dashboard is not served"
|
|
out=$(docker exec "$name" urutau doctor --json) || { echo "$out" >&2; fail "urutau doctor --json failed"; }
|
|
grep -q '"version"' <<<"$out" || fail "urutau doctor --json has no version"
|
|
[ "$(docker inspect -f '{{if .Config.Healthcheck}}yes{{end}}' "$name")" = yes ] || fail "image has no HEALTHCHECK"
|
|
[ "$(docker exec "$name" id -u)" != 0 ] || fail "daemon runs as root"
|
|
docker exec "$name" sh -c 'command -v curl' >/dev/null 2>&1 && fail "the image must not ship curl"
|
|
# 2.0 removed the federation: its variables stop the hub with a pointer to the guide.
|
|
out=$(docker run --rm -e URUTAU_TOKEN="$token" -e URUTAU_PEERS=old=https://example.org "$image" 2>&1) && fail "URUTAU_PEERS must stop the hub"
|
|
grep -q 'migration-2.0' <<<"$out" || fail "the URUTAU_PEERS error must point to docs/migration-2.0.md"
|
|
docker stop -t 10 "$name" >/dev/null
|
|
code=$(docker inspect -f '{{.State.ExitCode}}' "$name")
|
|
[ "$code" = 0 ] || fail "exit code $code after SIGTERM (expected 0: SIGTERM must stop serve)"
|
|
echo "smoke: $image ok"
|