All checks were successful
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m33s
CD Pipeline / build-and-deploy (push) Successful in 6m43s
CD Pipeline / post-deploy-checks (push) Successful in 1m48s
AWOOOI Harbor 110 Local Repair / workflow-shape (push) Successful in 1s
AWOOOI Harbor 110 Local Repair / harbor-110-local-repair (push) Successful in 50s
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import inspect
|
|
from types import SimpleNamespace
|
|
|
|
from src.api.v1.webhooks import (
|
|
_auto_repair_action_label,
|
|
_process_new_alert_background,
|
|
)
|
|
|
|
|
|
def test_auto_repair_action_label_includes_executed_steps() -> None:
|
|
result = SimpleNamespace(
|
|
playbook_id="PB-TEST",
|
|
executed_steps=["kubectl rollout restart deployment/api -n awoooi-prod"],
|
|
)
|
|
|
|
label = _auto_repair_action_label(result, fallback_target="api:awoooi-prod")
|
|
|
|
assert label == (
|
|
"auto_repair_playbook:PB-TEST "
|
|
"kubectl rollout restart deployment/api -n awoooi-prod"
|
|
)
|
|
|
|
|
|
def test_auto_repair_action_label_uses_target_when_steps_missing() -> None:
|
|
result = SimpleNamespace(playbook_id="PB-TEST", executed_steps=[])
|
|
|
|
label = _auto_repair_action_label(result, fallback_target="api:awoooi-prod")
|
|
|
|
assert label == "auto_repair_playbook:PB-TEST api:awoooi-prod"
|
|
|
|
|
|
def test_fallback_candidate_enters_single_writer_controlled_queue() -> None:
|
|
source = inspect.getsource(_process_new_alert_background)
|
|
|
|
assert "repair_candidate_result.candidate_found" in source
|
|
assert "_controlled_ai_policy_allows(fallback_create.risk_level)" in source
|
|
assert "_controlled_handoff = await _try_auto_repair_background" in source
|
|
assert 'primary_responsibility = "AI_CONTROLLED_EXECUTOR"' in source
|
|
assert '"automation_run_id": (' in source
|