Fase B3: CI bouwt en test alleen het master-CMS (SlpModularCms.Ci.slnf), publish alleen bij deploy, compile-sites (niet verplicht), rooktests na test-deploys
- backend-build/-test op SlpModularCms.Ci.slnf (Api + Core + modules + alle testprojecten; zonder Api.SlpSoftware/AndreaSlopFotografie/Slave). - publish-sls-test niet meer op pull_request. Vereiste checks master: backend-test + frontend-test (publish-check vervalt). - compile-sites: dotnet build van de drie site-projecten, niet verplicht. - scripts/smoke-site.sh + jobs smoke-sls-test/smoke-asf-test na deploy-*-test (modulelijst per site, noindex, robots, beschermde routes). - docs/deploy-en-testomgevingen.md bijgewerkt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
# Smoke test of a deployed site: anonymous GET requests only, no secrets.
|
||||
#
|
||||
# Usage: scripts/smoke-site.sh <url-on-the-host> <profile>
|
||||
# <url-on-the-host> any URL of the host, for example its /health URL; only scheme and host are used
|
||||
# <profile> sls-test | asf-test
|
||||
#
|
||||
# A site project is a thin composition (modules + appsettings.json), so what can still go wrong at deploy time is
|
||||
# the composition itself: a module missing, the wrong website mode, a missing setting. The CI builds and tests the
|
||||
# master CMS only; this script is the check that the deployed composition of a site is the one that was intended.
|
||||
# A failing check makes the CI run fail.
|
||||
set -u
|
||||
|
||||
base="$(printf '%s' "${1:?usage: smoke-site.sh <url-on-the-host> <profile>}" | sed -E 's#^(https?://[^/]+).*#\1#')"
|
||||
profile="${2:?profile (sls-test | asf-test) is required}"
|
||||
failures=0
|
||||
|
||||
curl_get() { curl -sS --max-time 20 --retry 4 --retry-delay 3 --retry-all-errors "$@"; }
|
||||
status_of() { curl_get -o /dev/null -w '%{http_code}' "$base$1"; }
|
||||
|
||||
pass() { echo "ok $1"; }
|
||||
fail() { echo "FAIL $1"; failures=$((failures + 1)); }
|
||||
|
||||
expect_status() { # path expected description
|
||||
local got; got="$(status_of "$1")"
|
||||
if [ "$got" = "$2" ]; then pass "$3 ($1 -> $got)"; else fail "$3 ($1 -> $got, expected $2)"; fi
|
||||
}
|
||||
|
||||
expect_header() { # path header-name expected-substring description
|
||||
local got; got="$(curl_get -D - -o /dev/null "$base$1" | tr -d '\r' | grep -i "^$2:" | head -1)"
|
||||
if printf '%s' "$got" | grep -qi "$3"; then pass "$4 ($1 $2)"; else fail "$4 ($1 $2: '${got:-<missing>}')"; fi
|
||||
}
|
||||
|
||||
expect_body() { # path expected-substring description
|
||||
if curl_get "$base$1" | grep -qF "$2"; then pass "$3 ($1)"; else fail "$3 ($1 does not contain '$2')"; fi
|
||||
}
|
||||
|
||||
echo "Smoke test '$profile' on $base"
|
||||
|
||||
expect_status /health 200 "health"
|
||||
|
||||
caps="$(curl_get "$base/api/v1/System/capabilities" || true)"
|
||||
module_listed() { printf '%s' "$caps" | grep -q "\"$1\""; }
|
||||
expect_module() { if module_listed "$1"; then pass "module $1 is loaded"; else fail "module $1 is NOT loaded (capabilities: ${caps:-<empty>})"; fi; }
|
||||
expect_no_module() { if module_listed "$1"; then fail "module $1 is loaded but must not be"; else pass "module $1 is not loaded"; fi; }
|
||||
|
||||
expect_status /api/v1/offerings 200 "public offerings"
|
||||
# 204 = no active banner, 200 = there is one; both are a healthy answer.
|
||||
banner="$(status_of '/api/v1/offerings/banner')"
|
||||
if [ "$banner" = "200" ] || [ "$banner" = "204" ]; then pass "public banner (/api/v1/offerings/banner -> $banner)"; else fail "public banner (-> $banner, expected 200 or 204)"; fi
|
||||
expect_status /api/v1/offerings/all 401 "the administrator list is protected"
|
||||
|
||||
# A test host is never indexed.
|
||||
expect_header / X-Robots-Tag noindex "noindex on the website"
|
||||
expect_body /robots.txt "Disallow: /" "robots.txt disallows everything"
|
||||
|
||||
case "$profile" in
|
||||
sls-test)
|
||||
for m in Identity Availability Offerings Contact Master; do expect_module "$m"; done
|
||||
expect_status /sitemap.xml 404 "no sitemap on a test host"
|
||||
;;
|
||||
asf-test)
|
||||
for m in Identity Availability Offerings Contact; do expect_module "$m"; done
|
||||
expect_no_module Master
|
||||
# Prerendered website: an unknown path is a real 404 (an SPA would answer 200).
|
||||
expect_status /smoke-test-path-that-does-not-exist 404 "unknown website path is a 404"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown profile '$profile' (use sls-test or asf-test)"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$failures" -gt 0 ]; then
|
||||
echo "Smoke test FAILED: $failures check(s)."
|
||||
exit 1
|
||||
fi
|
||||
echo "Smoke test passed."
|
||||
Reference in New Issue
Block a user