Fixed goroutine leak in 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
