@@ -1858,6 +1858,15 @@ func TestIngester_flushing(t *testing.T) {
18581858 i .FlushHandler (httptest .NewRecorder (), httptest .NewRequest ("POST" , "/flush" , nil ))
18591859
18601860 // Flush handler only triggers compactions, but doesn't wait for them to finish. Let's wait for a moment, and then verify.
1861+ test .Poll (t , 1 * time .Second , true , func () interface {} {
1862+ db := i .getTSDB (userID )
1863+ if db == nil {
1864+ return false
1865+ }
1866+ return db .Head ().NumSeries () == 0
1867+ })
1868+
1869+ // The above waiting only ensures compaction, waiting another second to register the Sync call.
18611870 time .Sleep (1 * time .Second )
18621871
18631872 verifyCompactedHead (t , i , true )
@@ -1888,17 +1897,20 @@ func TestIngester_flushing(t *testing.T) {
18881897
18891898 i .FlushHandler (httptest .NewRecorder (), httptest .NewRequest ("POST" , "/flush" , nil ))
18901899
1891- // Wait for compaction to finish.
1892- test .Poll (t , 5 * time .Second , true , func () interface {} {
1900+ // Flush handler only triggers compactions, but doesn't wait for them to finish. Let's wait for a moment, and then verify .
1901+ test .Poll (t , 1 * time .Second , true , func () interface {} {
18931902 db := i .getTSDB (userID )
18941903 if db == nil {
18951904 return false
18961905 }
1897-
1898- h := db .Head ()
1899- return h .NumSeries () == 0
1906+ return db .Head ().NumSeries () == 0
19001907 })
19011908
1909+ // The above waiting only ensures compaction, waiting another second to register the Sync call.
1910+ time .Sleep (1 * time .Second )
1911+
1912+ verifyCompactedHead (t , i , true )
1913+
19021914 m .AssertNumberOfCalls (t , "Sync" , 1 )
19031915
19041916 userDB := i .getTSDB (userID )
0 commit comments