From be1d1aec03f078a27b33c485d8ff35252840d0fa Mon Sep 17 00:00:00 2001 From: OoO Date: Tue, 5 May 2026 23:20:45 +0800 Subject: [PATCH] test(observability): include health in smoke suite --- docs/guides/observability_ui_governance.md | 1 + scripts/check_observability_pages.py | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/guides/observability_ui_governance.md b/docs/guides/observability_ui_governance.md index a82e010..2bac943 100644 --- a/docs/guides/observability_ui_governance.md +++ b/docs/guides/observability_ui_governance.md @@ -89,6 +89,7 @@ python3 scripts/check_observability_pages.py 此巡檢不只檢查 HTTP 200,也會檢查: +- `/health` 必須回 200 且包含 healthy marker。 - 不得出現 framework / database exception 文案。 - 每頁必須包含自己的核心標題與內容 marker。 - 每頁必須載入 `momo-observability-mode`、`observability-system.css` 與 topbar AI 觀測台 indicator。 diff --git a/scripts/check_observability_pages.py b/scripts/check_observability_pages.py index b8f1161..213629b 100644 --- a/scripts/check_observability_pages.py +++ b/scripts/check_observability_pages.py @@ -17,6 +17,12 @@ from observability_contract import CSS_ASSET_CHECKS, OBSERVABILITY_PAGES MIN_HTML_BYTES = 2500 +HEALTH_CHECK = ( + "/health", + "App Health", + ("healthy",), +) + GLOBAL_REQUIRED_MARKERS = [ "momo-observability-mode", "observability-system.css", @@ -54,6 +60,27 @@ def main() -> int: failed = False print(f"Observability page smoke: {args.base_url.rstrip('/')}") + health_path, health_label, health_markers = HEALTH_CHECK + try: + status, body = fetch_page(args.base_url, health_path, args.timeout) + missing_markers = [marker for marker in health_markers if marker not in body] + if status != 200 or missing_markers: + issues = [] + if status != 200: + issues.append("bad_status") + if missing_markers: + issues.append(f"missing_health_markers={missing_markers}") + print(f"- {health_label}: HTTP {status}, issues={issues}, FAIL") + failed = True + else: + print(f"- {health_label}: HTTP {status}, markers=ok") + except urllib.error.HTTPError as exc: + print(f"- {health_label}: HTTP {exc.code}, FAIL") + failed = True + except Exception as exc: + print(f"- {health_label}: {type(exc).__name__}: {exc}, FAIL") + failed = True + for page in OBSERVABILITY_PAGES: try: status, html = fetch_page(args.base_url, page.url, args.timeout)