Files
aevolution/tools/ci/server-image-smoke.sh
T

36 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# Smoke test for the evo-server image (M7.8, ADR-0066). Runs the image with the
# same restrictions a cluster uses; no network, no credentials, read-only root.
set -euo pipefail
image="${1:?image reference}"
run() {
docker run --rm --network none --read-only --cap-drop ALL \
--security-opt no-new-privileges "$@"
}
# Without configuration the server refuses to start (usage, exit 2), and never
# falls back to any default region or database.
set +e
usage="$(run "$image" 2>&1)"
code=$?
set -e
test "$code" -eq 2
grep -q '^usage: evo-server ' <<<"$usage"
# The bundled operations tool refuses to run without a subcommand too (M8.3).
set +e
tool="$(run --entrypoint /usr/local/bin/evo-world-clone "$image" 2>&1)"
code=$?
set -e
test "$code" -eq 2
grep -q '^usage: evo-world-clone ' <<<"$tool"
# Non-root, every shared library resolved, no credential material in the image.
run --entrypoint /bin/sh "$image" -c '
set -eu
test "$(id -u)" = 10001 && test "$(id -g)" = 10001
! ldd /usr/local/bin/evo-server | grep -q "not found"
! ldd /usr/local/bin/evo-world-clone | grep -q "not found"
test -z "$(find / -xdev \( -name "*pgpass*" -o -name "pg_service.conf" -o -name "*.pem" \
-o -name "*.key" \) -not -path "/etc/ssl/*" -not -path "/usr/lib/ssl/*" \
-not -path "/usr/share/*" -print 2>/dev/null)"
'
echo "server image smoke passed: $image"