test(observability): assert page content markers
Some checks failed
CD Pipeline / deploy (push) Failing after 4m55s

This commit is contained in:
OoO
2026-05-05 15:53:39 +08:00
parent 8643ed12ad
commit e7d567c6be
2 changed files with 37 additions and 2 deletions

View File

@@ -78,6 +78,12 @@ python3 scripts/check_observability_pages.py
或透過 quick review 選單執行第 7 項。
此巡檢不只檢查 HTTP 200也會檢查
- 不得出現 framework / database exception 文案。
- 每頁必須包含自己的核心標題與內容 marker。
- HTML 不能小到像空殼頁或錯誤 fallback。
```bash
python3 - <<'PY'
import urllib.request

View File

@@ -27,6 +27,21 @@ PAGES = [
("/observability/ppt_audit_history", "PPT"),
]
EXPECTED_MARKERS = {
"/observability/overview": ["觀測台總覽", "主機健康", "AI 呼叫"],
"/observability/agent_orchestration": ["Agent 編排矩陣", "LLM", "MCP", "RAG"],
"/observability/business_intel": ["商業面 × AI", "AI", "競品"],
"/observability/host_health": ["主機健康", "Ollama", "AutoHeal"],
"/observability/ai_calls": ["AI 呼叫", "Provider", "RAG"],
"/observability/budget": ["預算控管", "force", "throttle"],
"/observability/promotion_review": ["RAG 晉升審核", "Promotion", "ai_insights"],
"/observability/rag_queries": ["RAG 召回詳情", "最近 50", "hits"],
"/observability/quality_trend": ["反饋趨勢", "Caller", "蒸餾"],
"/observability/ppt_audit_history": ["PPT 視覺審核", "AiderHeal", "audit"],
}
MIN_HTML_BYTES = 2500
ERROR_NEEDLES = [
"Traceback",
"UndefinedError",
@@ -70,8 +85,22 @@ def main() -> int:
continue
found = [needle for needle in ERROR_NEEDLES if needle in html]
if status != 200 or found:
print(f"- {label}: HTTP {status}, issues={found or 'bad_status'}, FAIL")
missing_markers = [
marker for marker in EXPECTED_MARKERS.get(path, [])
if marker not in html
]
too_small = len(html.encode("utf-8")) < MIN_HTML_BYTES
if status != 200 or found or missing_markers or too_small:
issues = []
if status != 200:
issues.append("bad_status")
if found:
issues.extend(found)
if missing_markers:
issues.append(f"missing_markers={missing_markers}")
if too_small:
issues.append(f"html_too_small={len(html.encode('utf-8'))}B")
print(f"- {label}: HTTP {status}, issues={issues}, FAIL")
failed = True
else:
print(f"- {label}: HTTP {status}, issues=none")