mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
compactor: make event ordering well-defined in TestPeriodicPause
Fixes #5847
This commit is contained in:
parent
a61862acc7
commit
a1d823c2aa
@ -70,11 +70,13 @@ func TestPeriodicPause(t *testing.T) {
|
||||
tb.Run()
|
||||
tb.Pause()
|
||||
|
||||
// tb will collect 3 hours of revisions but not compact since paused
|
||||
n := int(time.Hour / checkCompactionInterval)
|
||||
for i := 0; i < 3*n; i++ {
|
||||
rg.Wait(1)
|
||||
fc.Advance(checkCompactionInterval)
|
||||
rg.Wait(1)
|
||||
}
|
||||
// tb ends up waiting for the clock
|
||||
|
||||
select {
|
||||
case a := <-compactable.Chan():
|
||||
@ -82,16 +84,19 @@ func TestPeriodicPause(t *testing.T) {
|
||||
case <-time.After(10 * time.Millisecond):
|
||||
}
|
||||
|
||||
// tb resumes to being blocked on the clock
|
||||
tb.Resume()
|
||||
rg.Wait(1)
|
||||
fc.Advance(checkCompactionInterval)
|
||||
|
||||
// unblock clock, will kick off a compaction at hour 3
|
||||
fc.Advance(checkCompactionInterval)
|
||||
a, err := compactable.Wait(1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(a[0].Params[0], &pb.CompactionRequest{Revision: int64(2*n) + 2}) {
|
||||
t.Errorf("compact request = %v, want %v", a[0].Params[0], &pb.CompactionRequest{Revision: int64(2*n) + 2})
|
||||
// compact the revision from hour 2
|
||||
wreq := &pb.CompactionRequest{Revision: int64(2*n + 1)}
|
||||
if !reflect.DeepEqual(a[0].Params[0], wreq) {
|
||||
t.Errorf("compact request = %v, want %v", a[0].Params[0], wreq.Revision)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user