tests checkpoints immediately and gives more of a time buffer (#4432)

pull/4438/head
Owen Diehl 4 years ago committed by GitHub
parent 1a4be0923e
commit 1921c3d428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      pkg/ingester/checkpoint_test.go

@ -330,11 +330,15 @@ func TestIngesterWALBackpressureCheckpoint(t *testing.T) {
} }
func expectCheckpoint(t *testing.T, walDir string, shouldExist bool, max time.Duration) { func expectCheckpoint(t *testing.T, walDir string, shouldExist bool, max time.Duration) {
once := make(chan struct{}, 1)
once <- struct{}{}
deadline := time.After(max) deadline := time.After(max)
for { for {
select { select {
case <-deadline: case <-deadline:
require.Fail(t, "timeout while waiting for checkpoint existence:", shouldExist) require.Fail(t, "timeout while waiting for checkpoint existence:", shouldExist)
case <-once: // Trick to ensure we check immediately before deferring to ticker.
default: default:
<-time.After(max / 10) // check 10x over the duration <-time.After(max / 10) // check 10x over the duration
} }
@ -637,7 +641,7 @@ func TestIngesterWALReplaysUnorderedToOrdered(t *testing.T) {
if waitForCheckpoint { if waitForCheckpoint {
// Ensure we have checkpointed now // Ensure we have checkpointed now
expectCheckpoint(t, walDir, true, ingesterConfig.WAL.CheckpointDuration*2) // give a bit of buffer expectCheckpoint(t, walDir, true, ingesterConfig.WAL.CheckpointDuration*10) // give a bit of buffer
// Add some more data after the checkpoint // Add some more data after the checkpoint
tmp := end tmp := end

Loading…
Cancel
Save