Merge pull request #14288 from VladSaioc/bugfix-goleak-watchtest

Fixed goroutine leak in tests/integration/clientv3/watch_test.go
This commit is contained in:
Benjamin Wang 2022-08-01 06:55:57 +08:00 committed by GitHub
commit 68c0cf834a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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