29 lines
1.5 KiB
Bash
Executable File
29 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Smoke-tests a Xexéu image: the API and the dashboard answer,
|
|
# xexeu doctor reports ok, a HEALTHCHECK is declared and SIGTERM stops the daemon cleanly.
|
|
# 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="xexeu-smoke-$$-$RANDOM"
|
|
trap 'docker rm -f "$name" >/dev/null 2>&1 || true' EXIT
|
|
fail() { echo "smoke: $*" >&2; docker logs "$name" >&2 2>&1 || true; exit 1; }
|
|
|
|
docker run -d --name "$name" "$image" >/dev/null
|
|
for _ in $(seq 1 30); do
|
|
docker exec "$name" curl -fsS http://127.0.0.1:8788/api/health >/dev/null 2>&1 && break
|
|
sleep 1
|
|
done
|
|
docker exec "$name" curl -fsS http://127.0.0.1:8788/api/health | grep -q '"status":"ok"' || fail "/api/health did not answer"
|
|
docker exec "$name" curl -fsS http://127.0.0.1:8788/ | grep -qi '<!doctype html' || fail "dashboard is not served"
|
|
docker exec "$name" xexeu doctor --json | grep -q '"version"' || fail "xexeu doctor --json failed"
|
|
[ "$(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 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"
|