fix(api): honor upstream docker repair success
This commit is contained in:
@@ -497,6 +497,44 @@ class TestAutoRepairService:
|
||||
|
||||
assert route is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_execute_legacy_ssh_restart_noops_when_upstream_repair_succeeded(
|
||||
self,
|
||||
service,
|
||||
monkeypatch,
|
||||
):
|
||||
"""Do not restart twice when the host monitor already repaired it."""
|
||||
incident = create_test_incident(
|
||||
severity=Severity.P2,
|
||||
alert_category="infrastructure",
|
||||
alert_name="DockerContainerUnhealthy",
|
||||
)
|
||||
incident.signals[0].labels.update({
|
||||
"host": "wooo",
|
||||
"container": "stockplatform-v2-edge-1",
|
||||
"source": "docker-health-monitor",
|
||||
"repair_action": "restarted",
|
||||
"repair_result": "success",
|
||||
})
|
||||
step = RepairStep(
|
||||
step_number=1,
|
||||
action_type=ActionType.SSH_COMMAND,
|
||||
command='ssh {host} \'docker inspect {container} --format="{{.State.Health.Status}}" && docker restart {container}\'',
|
||||
risk_level=RiskLevel.MEDIUM,
|
||||
requires_approval=False,
|
||||
)
|
||||
|
||||
async def fail_if_called(*args, **kwargs):
|
||||
raise AssertionError("MCP Gateway should not be called after upstream repair success")
|
||||
|
||||
monkeypatch.setattr(service, "_execute_ssh_mcp_route", fail_if_called)
|
||||
|
||||
result = await service._execute_step(incident, step)
|
||||
|
||||
assert result.startswith("SUCCESS: upstream repair already completed")
|
||||
assert "docker-health-monitor" in result
|
||||
assert "stockplatform-v2-edge-1" in result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_execute_legacy_ssh_diagnostic_uses_mcp_gateway(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user