Пофиксила тест === alert firing and resolved ===
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user