From a47af03eefd6f24a809975458b22f0324b07414b Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Mon, 19 Oct 2026 23:46:13 +0200 Subject: [PATCH] =?UTF-8?q?f-78:=20e2e:=20watchdog=5Fquiet=20r=C3=A9ussit?= =?UTF-8?q?=20sans=20alerte=20quand=20aucune=20exclusion=20n'est=20donn?= =?UTF-8?q?=C3=A9e=20#78?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: GnomeZworc --- test/e2e/lib/evpn.sh | 3 ++- test/e2e/run_test.sh | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/e2e/lib/evpn.sh b/test/e2e/lib/evpn.sh index 1ce05c9..2ffba8a 100644 --- a/test/e2e/lib/evpn.sh +++ b/test/e2e/lib/evpn.sh @@ -81,7 +81,8 @@ watchdog_alerts () { watchdog_quiet () { local out - out=$(watchdog_alerts "${1:-300}" | { if [ -n "${2:-}" ]; then grep -vF -- "${2}"; else cat; fi; }) || return 0 + out=$(watchdog_alerts "${1:-300}" | { if [ -n "${2:-}" ]; then grep -vF -- "${2}"; else cat; fi; }) + [ -z "${out}" ] && return 0 printf '%s\n' "${out}" return 1 } diff --git a/test/e2e/run_test.sh b/test/e2e/run_test.sh index f417fd7..186424a 100755 --- a/test/e2e/run_test.sh +++ b/test/e2e/run_test.sh @@ -232,6 +232,16 @@ test_api_code_returns_the_http_status () { teardown } +test_watchdog_quiet_passes_without_alert_and_fails_on_one () { + setup "watchdog_quiet : réussit sans alerte, avec ou sans exclusion ; échoue sur une alerte non exclue" + local alert='{"level":"ERROR","msg":"watchdog: inconsistency detected","problem":"stale dhcp reservation on the server"}' + [[ $(node "journalctl () { :; }; watchdog_quiet 300 && echo OUI") == OUI ]] || fail "journal vide, sans exclusion : échec" + [[ $(node "journalctl () { :; }; watchdog_quiet 300 'stale dhcp' && echo OUI") == OUI ]] || fail "journal vide, avec exclusion : échec" + [[ $(node "journalctl () { echo '${alert}'; }; watchdog_quiet 300 >/dev/null || echo NON") == NON ]] || fail "alerte acceptée sans exclusion" + [[ $(node "journalctl () { echo '${alert}'; }; watchdog_quiet 300 'stale dhcp' && echo OUI") == OUI ]] || fail "alerte exclue refusée" + teardown +} + test_watchdog_reported_matches_only_watchdog_alerts () { setup "watchdog_reported : alerte du watchdog contenant le texte, rien d'autre" local alert='{"level":"ERROR","msg":"watchdog: inconsistency detected","kind":"vpc","name":"vp-s8","problem":"route 10.242.1.99/32 exported in vrf-s8 without a running owner: its traffic is black-holed"}'