From cad92706cfca4a01c513e13c87570fefbf9dbe28 Mon Sep 17 00:00:00 2001 From: sfzhu93 <42506672+sfzhu93@users.noreply.github.com> Date: Thu, 30 Jan 2020 13:45:59 -0500 Subject: [PATCH] in multiple packages: fixed goroutine leak bugs in tests (#11569) --- clientv3/integration/kv_test.go | 2 +- clientv3/integration/txn_test.go | 2 +- etcdserver/server_test.go | 4 ++-- mvcc/kvstore_test.go | 2 +- mvcc/watcher_test.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clientv3/integration/kv_test.go b/clientv3/integration/kv_test.go index 8e409b936..4f2a28a3e 100644 --- a/clientv3/integration/kv_test.go +++ b/clientv3/integration/kv_test.go @@ -710,7 +710,7 @@ func TestKVGetRetry(t *testing.T) { clus.Members[fIdx].Stop(t) - donec := make(chan struct{}) + donec := make(chan struct{}, 1) go func() { // Get will fail, but reconnect will trigger gresp, gerr := kv.Get(ctx, "foo") diff --git a/clientv3/integration/txn_test.go b/clientv3/integration/txn_test.go index 212ecdc33..d9e6b8d5a 100644 --- a/clientv3/integration/txn_test.go +++ b/clientv3/integration/txn_test.go @@ -119,7 +119,7 @@ func TestTxnReadRetry(t *testing.T) { clus.Members[0].Stop(t) <-clus.Members[0].StopNotify() - donec := make(chan struct{}) + donec := make(chan struct{}, 1) go func() { _, err := kv.Txn(context.TODO()).Then(thenOps[i]...).Commit() if err != nil { diff --git a/etcdserver/server_test.go b/etcdserver/server_test.go index 4c5d5883f..f54cfc148 100644 --- a/etcdserver/server_test.go +++ b/etcdserver/server_test.go @@ -838,7 +838,7 @@ func TestSync(t *testing.T) { srv.applyV2 = &applierV2store{store: srv.v2store, cluster: srv.cluster} // check that sync is non-blocking - done := make(chan struct{}) + done := make(chan struct{}, 1) go func() { srv.sync(10 * time.Second) done <- struct{}{} @@ -883,7 +883,7 @@ func TestSyncTimeout(t *testing.T) { srv.applyV2 = &applierV2store{store: srv.v2store, cluster: srv.cluster} // check that sync is non-blocking - done := make(chan struct{}) + done := make(chan struct{}, 1) go func() { srv.sync(0) done <- struct{}{} diff --git a/mvcc/kvstore_test.go b/mvcc/kvstore_test.go index eb9b1f130..b00768544 100644 --- a/mvcc/kvstore_test.go +++ b/mvcc/kvstore_test.go @@ -662,7 +662,7 @@ func TestConcurrentReadNotBlockingWrite(t *testing.T) { readTx1 := s.Read(traceutil.TODO()) // write should not be blocked by reads - done := make(chan struct{}) + done := make(chan struct{}, 1) go func() { s.Put([]byte("foo"), []byte("newBar"), lease.NoLease) // this is a write Txn done <- struct{}{} diff --git a/mvcc/watcher_test.go b/mvcc/watcher_test.go index f3bc9e159..679ab441d 100644 --- a/mvcc/watcher_test.go +++ b/mvcc/watcher_test.go @@ -355,7 +355,7 @@ func TestWatcherWatchWithFilter(t *testing.T) { } w.Watch(0, []byte("foo"), nil, 0, filterPut) - done := make(chan struct{}) + done := make(chan struct{}, 1) go func() { <-w.Chan()