From 5c23eb937eccd4160f2e55115fbba084992f4171 Mon Sep 17 00:00:00 2001 From: knight42 Date: Wed, 12 Aug 2020 01:58:07 +0800 Subject: [PATCH] test(endpoints): deflake TestWatchHTTPTimeout Signed-off-by: knight42 Kubernetes-commit: 50e8287e6df67428ab5871af530fb10f6eee19de --- pkg/endpoints/watch_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/endpoints/watch_test.go b/pkg/endpoints/watch_test.go index e588bfb05..998888c77 100644 --- a/pkg/endpoints/watch_test.go +++ b/pkg/endpoints/watch_test.go @@ -844,7 +844,16 @@ func TestWatchHTTPTimeout(t *testing.T) { close(timeoutCh) select { case <-done: - if !watcher.IsStopped() { + eventCh := watcher.ResultChan() + select { + case _, opened := <-eventCh: + if opened { + t.Errorf("Watcher received unexpected event") + } + if !watcher.IsStopped() { + t.Errorf("Watcher is not stopped") + } + case <-time.After(wait.ForeverTestTimeout): t.Errorf("Leaked watch on timeout") } case <-time.After(wait.ForeverTestTimeout):