From 2479fb42f0a9bb45c2e82f11efc73c0a75fc492c Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 5 Jul 2022 15:27:26 +0200 Subject: [PATCH] Improve notifier queue test to reduce flakiness (#10984) Signed-off-by: Julien Pivotto --- notifier/notifier_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/notifier/notifier_test.go b/notifier/notifier_test.go index f3d7593ec..163e55354 100644 --- a/notifier/notifier_test.go +++ b/notifier/notifier_test.go @@ -590,8 +590,13 @@ func TestHangingNotifier(t *testing.T) { close(done) }() + var calledOnce bool // Setting up a bad server. This server hangs for 2 seconds. badServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if calledOnce { + t.Fatal("hanging server called multiple times") + } + calledOnce = true select { case <-done: case <-time.After(2 * time.Second): @@ -672,8 +677,8 @@ func TestHangingNotifier(t *testing.T) { }() select { - case <-time.After(300 * time.Millisecond): - t.Fatalf("Timeout after 300 milliseconds, targets not synced in time.") + case <-time.After(1 * time.Second): + t.Fatalf("Timeout after 1 second, targets not synced in time.") case <-changed: // The good server has been hit in less than 3 seconds, therefore // targets have been updated before a second call could be made to the