Skip to content

Commit

Permalink
cache: TestCacheMap: wait grow-shrink goroutine to stop
Browse files Browse the repository at this point in the history
  • Loading branch information
syndtr committed Jun 13, 2022
1 parent 467c5cb commit 686510c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions leveldb/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -212,6 +213,7 @@ func TestCacheMap(t *testing.T) {
h.Release()
}
}
growShrinkStop <- true
}()

wg.Wait()
Expand All @@ -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())
Expand Down

0 comments on commit 686510c

Please sign in to comment.