From 2b8854ba2850c6c3bfd43ecc5fb3996eab5bc105 Mon Sep 17 00:00:00 2001 From: Wojciech Tyczynski Date: Tue, 22 Dec 2015 09:54:05 +0100 Subject: [PATCH] Close watchers in tests --- pkg/registry/generic/etcd/etcd_test.go | 1 + pkg/storage/etcd/etcd_watcher_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/pkg/registry/generic/etcd/etcd_test.go b/pkg/registry/generic/etcd/etcd_test.go index 0a8109d61ff..01322cf3f19 100644 --- a/pkg/registry/generic/etcd/etcd_test.go +++ b/pkg/registry/generic/etcd/etcd_test.go @@ -605,6 +605,7 @@ func TestEtcdWatch(t *testing.T) { } } } + wi.Stop() } server.Terminate(t) diff --git a/pkg/storage/etcd/etcd_watcher_test.go b/pkg/storage/etcd/etcd_watcher_test.go index fc7453c5b16..ebebe8d3ea3 100644 --- a/pkg/storage/etcd/etcd_watcher_test.go +++ b/pkg/storage/etcd/etcd_watcher_test.go @@ -246,6 +246,7 @@ func TestWatch(t *testing.T) { if err != nil { t.Fatalf("Unexpected error: %v", err) } + defer watching.Stop() // Test normal case pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}} @@ -292,6 +293,7 @@ func TestWatchEtcdState(t *testing.T) { if err != nil { t.Fatalf("Unexpected error: %v", err) } + defer watching.Stop() endpoint := &api.Endpoints{ ObjectMeta: api.ObjectMeta{Name: "foo"}, @@ -356,6 +358,7 @@ func TestWatchFromZeroIndex(t *testing.T) { if err != nil { t.Fatalf("Unexpected error: %v", err) } + defer watching.Stop() // marked as modified b/c of concatenation event := <-watching.ResultChan() @@ -391,6 +394,7 @@ func TestWatchListFromZeroIndex(t *testing.T) { if err != nil { t.Fatalf("Unexpected error: %v", err) } + defer watching.Stop() // creates key/foo which should trigger the WatchList for "key" pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}} @@ -423,6 +427,7 @@ func TestWatchListIgnoresRootKey(t *testing.T) { if err != nil { t.Fatalf("Unexpected error: %v", err) } + defer watching.Stop() // creates key/foo which should trigger the WatchList for "key" err = h.Create(context.TODO(), key, pod, pod, 0)