test: add post-deploy smoke checks
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
base_url="${1:-http://localhost:8088}"
|
||||
base_url="${base_url%/}"
|
||||
get() { curl --fail --silent --show-error "$@"; }
|
||||
|
||||
live="$(get "$base_url/api/health?probe=live")"
|
||||
ready="$(get "$base_url/api/health?probe=ready")"
|
||||
home="$(get "$base_url/")"
|
||||
rss_headers="$(get -I "$base_url/rss.xml")"
|
||||
if [[ -n "${METRICS_TOKEN:-}" ]]; then metrics="$(get -H "Authorization: Bearer $METRICS_TOKEN" "$base_url/api/metrics")"; else metrics="$(get "$base_url/api/metrics")"; fi
|
||||
|
||||
[[ "$live" == *'"status":"live"'* ]] || { echo "Liveness probe did not return live" >&2; exit 1; }
|
||||
[[ "$ready" == *'"status":"ready"'* && "$ready" == *'"database":"ok"'* ]] || { echo "Readiness probe did not confirm database" >&2; exit 1; }
|
||||
[[ "$home" == *'<title>Mebbling</title>'* ]] || { echo "Home page title missing" >&2; exit 1; }
|
||||
[[ "${rss_headers,,}" == *'content-type: application/rss+xml'* ]] || { echo "RSS content type missing" >&2; exit 1; }
|
||||
[[ "$metrics" == *'mebbling_sources_enabled'* ]] || { echo "Metrics response is incomplete" >&2; exit 1; }
|
||||
printf 'Smoke test passed: %s\n' "$base_url"
|
||||
Reference in New Issue
Block a user