Пофиксила тест === alert firing and resolved ===

This commit is contained in:
vasyukova
2026-10-30 18:48:05 +03:00
parent a55e0e60c0
commit 13d4411534
+12 -3
View File
@@ -399,10 +399,19 @@ def _wait_alert(name: str, state: str, timeout: float = 240.0):
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
alerts = _prom_alerts()
for a in alerts:
labels = a.get("labels", {})
if labels.get("alertname") == name and a.get("state") == state:
# Prometheus /api/v1/alerts возвращает только pending/firing.
# Состояние "inactive" == алерта с таким alertname нет в списке.
active = [
a for a in alerts
if a.get("labels", {}).get("alertname") == name
]
if state == "inactive":
if not active:
return
else:
for a in active:
if a.get("state") == state:
return
time.sleep(3)
raise Failure("alert %s never reached %s" % (name, state))