From cbfddfe63f0b392ed2d38bc3f73149d5fb503bea Mon Sep 17 00:00:00 2001 From: VladSaioc Date: Sun, 31 Jul 2022 23:07:06 +0200 Subject: [PATCH] Fixed goroutine leak in tests/integration/clientv3/watch_test.go Signed-off-by: VladSaioc --- tests/integration/clientv3/watch_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/integration/clientv3/watch_test.go b/tests/integration/clientv3/watch_test.go index a1f1dc287..4e2c6ab96 100644 --- a/tests/integration/clientv3/watch_test.go +++ b/tests/integration/clientv3/watch_test.go @@ -27,7 +27,7 @@ import ( mvccpb "go.etcd.io/etcd/api/v3/mvccpb" "go.etcd.io/etcd/api/v3/v3rpc/rpctypes" "go.etcd.io/etcd/api/v3/version" - "go.etcd.io/etcd/client/v3" + clientv3 "go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/server/v3/etcdserver/api/v3rpc" integration2 "go.etcd.io/etcd/tests/v3/framework/integration" "google.golang.org/grpc/metadata" @@ -74,6 +74,12 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) { keys := []string{"foo", "bar", "baz"} donec := make(chan struct{}) + // wait for watcher shutdown + defer func() { + for i := 0; i < len(keys)+1; i++ { + <-donec + } + }() readyc := make(chan struct{}) for _, k := range keys { // key watcher @@ -156,10 +162,6 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) { } } } - // wait for watcher shutdown - for i := 0; i < len(keys)+1; i++ { - <-donec - } } // TestWatchRange tests watcher creates ranges