Skip to content

Commit

Permalink
test: fix TestHashKVWhenCompacting: ensure all goroutine finished and…
Browse files Browse the repository at this point in the history
… decrease compact count

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Jan 24, 2024
1 parent 15f95ec commit 4bfeba7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/storage/mvcc/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,10 @@ func TestHashKVWhenCompacting(t *testing.T) {
}
}()

// Compact the store in a goroutine, using RevisionTombstone 9900 to 10000 and close donec when finished
// Compact the store in a goroutine, using RevisionTombstone 9950 to 10000 and close donec when finished
go func() {
defer close(donec)
for i := 100; i >= 0; i-- {
for i := 50; i >= 0; i-- {
_, err := s.Compact(traceutil.TODO(), int64(rev-i))
if err != nil {
t.Error(err)
Expand All @@ -620,10 +620,11 @@ func TestHashKVWhenCompacting(t *testing.T) {

select {
case <-donec:
wg.Wait()
case <-time.After(10 * time.Second):
testutil.FatalStack(t, "timeout")
}

wg.Wait()
}

// TestHashKVWithCompactedAndFutureRevisions ensures that HashKV returns a correct hash when called
Expand Down

0 comments on commit 4bfeba7

Please sign in to comment.