compactor: make event ordering well-defined in TestPeriodicPause
Fixes #5847
This commit is contained in:
@ -70,11 +70,13 @@ func TestPeriodicPause(t *testing.T) {
|
|||||||
tb.Run()
|
tb.Run()
|
||||||
tb.Pause()
|
tb.Pause()
|
||||||
|
|
||||||
|
// tb will collect 3 hours of revisions but not compact since paused
|
||||||
n := int(time.Hour / checkCompactionInterval)
|
n := int(time.Hour / checkCompactionInterval)
|
||||||
for i := 0; i < 3*n; i++ {
|
for i := 0; i < 3*n; i++ {
|
||||||
rg.Wait(1)
|
|
||||||
fc.Advance(checkCompactionInterval)
|
fc.Advance(checkCompactionInterval)
|
||||||
|
rg.Wait(1)
|
||||||
}
|
}
|
||||||
|
// tb ends up waiting for the clock
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case a := <-compactable.Chan():
|
case a := <-compactable.Chan():
|
||||||
@ -82,16 +84,19 @@ func TestPeriodicPause(t *testing.T) {
|
|||||||
case <-time.After(10 * time.Millisecond):
|
case <-time.After(10 * time.Millisecond):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tb resumes to being blocked on the clock
|
||||||
tb.Resume()
|
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)
|
a, err := compactable.Wait(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(a[0].Params[0], &pb.CompactionRequest{Revision: int64(2*n) + 2}) {
|
// compact the revision from hour 2
|
||||||
t.Errorf("compact request = %v, want %v", a[0].Params[0], &pb.CompactionRequest{Revision: int64(2*n) + 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user