mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
server/storage/mvcc: deflake TestHashKVWhenCompacting
The HashByRev-goroutines exit since receive `donec` notification. The Check-computed-hashes goroutine could not have chance to get the hash result and be stuck forever. We should add case for donec when we wait for hash result. Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
ea9ef764a6
commit
a6f7bbe560
@ -591,18 +591,17 @@ func TestHashKVWhenCompacting(t *testing.T) {
|
||||
defer wg.Done()
|
||||
revHash := make(map[int64]uint32)
|
||||
for {
|
||||
r := <-hashCompactc
|
||||
if revHash[r.compactRev] == 0 {
|
||||
revHash[r.compactRev] = r.hash
|
||||
}
|
||||
if r.hash != revHash[r.compactRev] {
|
||||
t.Errorf("Hashes differ (current %v) != (saved %v)", r.hash, revHash[r.compactRev])
|
||||
}
|
||||
|
||||
select {
|
||||
case r := <-hashCompactc:
|
||||
if revHash[r.compactRev] == 0 {
|
||||
revHash[r.compactRev] = r.hash
|
||||
}
|
||||
|
||||
if r.hash != revHash[r.compactRev] {
|
||||
t.Errorf("Hashes differ (current %v) != (saved %v)", r.hash, revHash[r.compactRev])
|
||||
}
|
||||
case <-donec:
|
||||
return
|
||||
default:
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
Loading…
x
Reference in New Issue
Block a user