From 686510c64e9b9535b72c7ce8bbda87ef1d2744ba Mon Sep 17 00:00:00 2001 From: Suryandaru Triandana Date: Mon, 13 Jun 2022 10:35:33 +0700 Subject: [PATCH] cache: TestCacheMap: wait grow-shrink goroutine to stop --- leveldb/cache/cache_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/leveldb/cache/cache_test.go b/leveldb/cache/cache_test.go index cbd64f34..a0dfb384 100644 --- a/leveldb/cache/cache_test.go +++ b/leveldb/cache/cache_test.go @@ -200,6 +200,7 @@ func TestCacheMap(t *testing.T) { } // Emulate constant grow-shrink. + growShrinkStop := make(chan bool, 1) go func() { handles := make([]*Handle, 100000) for atomic.LoadInt32(&done) == 0 { @@ -212,6 +213,7 @@ func TestCacheMap(t *testing.T) { h.Release() } } + growShrinkStop <- true }() wg.Wait() @@ -237,6 +239,8 @@ func TestCacheMap(t *testing.T) { } } + <-growShrinkStop + require.Zero(t, c.Nodes()) require.Zero(t, c.Size()) t.Logf("STATS: %#v", c.GetStats())