Skip to content

Commit 5830344

Browse files
authored
fix test that is flaky in CI (#19)
1 parent e9002a1 commit 5830344

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

dsqueue_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,22 @@ func TestIdleFlush(t *testing.T) {
210210
t.Fatal("expected nothing in datastore")
211211
}
212212

213-
time.Sleep(2 * time.Second)
214-
215-
n, err = countItems(ctx, dsn)
216-
if err != nil {
217-
t.Fatal(err)
213+
wanted := len(cids) - 1
214+
got := 0
215+
for range 5 {
216+
time.Sleep(time.Second)
217+
n, err = countItems(ctx, dsn)
218+
if err != nil {
219+
t.Fatal(err)
220+
}
221+
got += n
222+
if got >= wanted {
223+
break
224+
}
218225
}
219-
expect := len(cids) - 1
220-
if n != expect {
221-
t.Fatalf("should have flushed %d cids to datastore, got %d", expect, n)
226+
227+
if got != wanted {
228+
t.Fatalf("should have flushed %d cids to datastore, got %d", wanted, got)
222229
}
223230
}
224231

0 commit comments

Comments
 (0)