test(observability): include health in smoke suite
All checks were successful
CD Pipeline / deploy (push) Successful in 4m4s
All checks were successful
CD Pipeline / deploy (push) Successful in 4m4s
This commit is contained in:
@@ -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。
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user