Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions pkg/ingester/ingester_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,15 @@ func TestIngester_flushing(t *testing.T) {
i.FlushHandler(httptest.NewRecorder(), httptest.NewRequest("POST", "/flush", nil))

// Flush handler only triggers compactions, but doesn't wait for them to finish. Let's wait for a moment, and then verify.
test.Poll(t, 1*time.Second, true, func() interface{} {
db := i.getTSDB(userID)
if db == nil {
return false
}
return db.Head().NumSeries() == 0
})

// The above waiting only ensures compaction, waiting another second to register the Sync call.
time.Sleep(1 * time.Second)

verifyCompactedHead(t, i, true)
Expand Down Expand Up @@ -1888,17 +1897,20 @@ func TestIngester_flushing(t *testing.T) {

i.FlushHandler(httptest.NewRecorder(), httptest.NewRequest("POST", "/flush", nil))

// Wait for compaction to finish.
test.Poll(t, 5*time.Second, true, func() interface{} {
// Flush handler only triggers compactions, but doesn't wait for them to finish. Let's wait for a moment, and then verify.
test.Poll(t, 1*time.Second, true, func() interface{} {
db := i.getTSDB(userID)
if db == nil {
return false
}

h := db.Head()
return h.NumSeries() == 0
return db.Head().NumSeries() == 0
})

// The above waiting only ensures compaction, waiting another second to register the Sync call.
time.Sleep(1 * time.Second)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sleep it similar to what we are doing above for other test cases. Additionally added polling for other cases.


verifyCompactedHead(t, i, true)

m.AssertNumberOfCalls(t, "Sync", 1)

userDB := i.getTSDB(userID)
Expand Down