fix(api): route runaway host alerts to ai event packets
Some checks failed
CD Pipeline / tests (push) Successful in 1m44s
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / build-and-deploy (push) Successful in 7m8s
CD Pipeline / post-deploy-checks (push) Successful in 2m56s
Ansible / Reboot Recovery Contract / validate (push) Has been cancelled
Some checks failed
CD Pipeline / tests (push) Successful in 1m44s
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / build-and-deploy (push) Successful in 7m8s
CD Pipeline / post-deploy-checks (push) Successful in 2m56s
Ansible / Reboot Recovery Contract / validate (push) Has been cancelled
This commit is contained in:
@@ -91,6 +91,49 @@ root 364 181 0.7 3491396 494608 ? Rl 05:56 0:18 /opt/hostedto
|
||||
assert "processChild.js" not in result
|
||||
|
||||
|
||||
def test_orphan_browser_alert_becomes_runaway_process_event_packet() -> None:
|
||||
"""HostOrphanBrowserSmokeHighCpu 必須變成 runaway process 專屬事件包。"""
|
||||
raw_alert = (
|
||||
'alertname="HostOrphanBrowserSmokeHighCpu" host="110" '
|
||||
'rule="stockplatform_headless_smoke" '
|
||||
"description=\"orphan Chrome smoke group detected\""
|
||||
)
|
||||
|
||||
result = format_host_resource_alert_card(raw_alert)
|
||||
|
||||
assert "主機資源告警|110" in result
|
||||
assert "ai_automation_alert_card_v1" in result
|
||||
assert "orphan_browser_smoke_runaway_process" in result
|
||||
assert "HostOrphanBrowserSmokeHighCpu" in result
|
||||
assert "stockplatform_headless_smoke" in result
|
||||
assert "host-runaway-process-remediation.py" in result
|
||||
assert "dry-run" in result
|
||||
assert "gated SIGTERM" in result
|
||||
assert "KM / PlayBook / Verifier" in result
|
||||
assert "runtime_write_gate=0" in result
|
||||
assert "不 kill process" in result
|
||||
assert "Docker" in result
|
||||
|
||||
|
||||
def test_ci_runner_load_alert_becomes_capacity_event_packet() -> None:
|
||||
"""HostCiRunnerLoadSaturation 不可被誤導成可 kill 的 runaway process。"""
|
||||
raw_alert = (
|
||||
'alertname="HostCiRunnerLoadSaturation" host="110" '
|
||||
"awoooi_host_gitea_actions_active_container_count 2"
|
||||
)
|
||||
|
||||
result = format_host_resource_alert_card(raw_alert)
|
||||
|
||||
assert "主機資源告警|110" in result
|
||||
assert "ci_runner_load_saturation" in result
|
||||
assert "CI load evidence packet" in result
|
||||
assert "Gitea Actions run" in result
|
||||
assert "合法 CI" in result
|
||||
assert "不做 process remediation" in result
|
||||
assert "runtime_write_gate=0" in result
|
||||
assert "不 kill process" in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_alert_notification_normalizes_host_resource_raw_dump(monkeypatch) -> None:
|
||||
"""send_alert_notification 是最後出口,必須自動套用 AI 自動化事件包。"""
|
||||
|
||||
Reference in New Issue
Block a user