From 25af6e7b7be3f5a046569f10a6e0a7df0f31f960 Mon Sep 17 00:00:00 2001 From: Sugu Sougoumarane Date: Sat, 18 Apr 2020 16:03:42 -0700 Subject: [PATCH] yaml: deflake pool_test Signed-off-by: Sugu Sougoumarane --- go/vt/vttablet/tabletserver/connpool/pool_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/go/vt/vttablet/tabletserver/connpool/pool_test.go b/go/vt/vttablet/tabletserver/connpool/pool_test.go index acde420b707..139d191db8e 100644 --- a/go/vt/vttablet/tabletserver/connpool/pool_test.go +++ b/go/vt/vttablet/tabletserver/connpool/pool_test.go @@ -18,6 +18,7 @@ package connpool import ( "runtime" + "sync" "testing" "time" @@ -80,7 +81,10 @@ func TestConnPoolMaxWaiters(t *testing.T) { require.NoError(t, err) // waiter 1 + var wg sync.WaitGroup + wg.Add(1) go func() { + defer wg.Done() c1, err := connPool.Get(context.Background()) assert.NoError(t, err) c1.Recycle() @@ -92,11 +96,14 @@ func TestConnPoolMaxWaiters(t *testing.T) { break } } + + // waiter 2 _, err = connPool.Get(context.Background()) assert.EqualError(t, err, "pool TestPool waiter count exceeded") // This recycle will make waiter1 succeed. dbConn.Recycle() + wg.Wait() } func TestConnPoolGetEmptyDebugConfig(t *testing.T) {