From d87bd2c87cbc791dd45a13cf1f9ea6022e92723c Mon Sep 17 00:00:00 2001 From: yzm Date: Tue, 16 Jul 2019 10:25:10 -0700 Subject: [PATCH 1/2] integration: add WaitGroup to prevent calling t.Fatalf after TestV3WatchCurrentPutOverlap function return It could cause a panic when it happens Fixes #10886 --- integration/v3_watch_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/integration/v3_watch_test.go b/integration/v3_watch_test.go index 2de2db4c4..940179bb3 100644 --- a/integration/v3_watch_test.go +++ b/integration/v3_watch_test.go @@ -479,8 +479,11 @@ func TestV3WatchCurrentPutOverlap(t *testing.T) { // last mod_revision that will be observed nrRevisions := 32 // first revision already allocated as empty revision + var wg sync.WaitGroup for i := 1; i < nrRevisions; i++ { + wg.Add(1) go func() { + defer wg.Done() kvc := toGRPC(clus.RandClient()).KV req := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")} if _, err := kvc.Put(context.TODO(), req); err != nil { @@ -488,6 +491,7 @@ func TestV3WatchCurrentPutOverlap(t *testing.T) { } }() } + wg.Wait() // maps watcher to current expected revision progress := make(map[int64]int64) From 3737979532b7d54df3f945fa7d9cf724c1c4f4de Mon Sep 17 00:00:00 2001 From: yzm Date: Tue, 16 Jul 2019 12:43:55 -0700 Subject: [PATCH 2/2] move wg.Wait() after loop --- integration/v3_watch_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/v3_watch_test.go b/integration/v3_watch_test.go index 940179bb3..9fe2b8024 100644 --- a/integration/v3_watch_test.go +++ b/integration/v3_watch_test.go @@ -491,7 +491,6 @@ func TestV3WatchCurrentPutOverlap(t *testing.T) { } }() } - wg.Wait() // maps watcher to current expected revision progress := make(map[int64]int64) @@ -544,6 +543,8 @@ func TestV3WatchCurrentPutOverlap(t *testing.T) { if rok, nr := waitResponse(wStream, time.Second); !rok { t.Errorf("unexpected pb.WatchResponse is received %+v", nr) } + + wg.Wait() } // TestV3WatchEmptyKey ensures synced watchers see empty key PUTs as PUT events