Skip to content

Commit

Permalink
Workaround for racy testReaderStats test (segmentio#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevevls authored Feb 21, 2019
1 parent ecca8c3 commit 809ee76
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ func testReaderStats(t *testing.T, ctx context.Context, r *Reader) {
bytes += int64(len(m.Key) + len(m.Value))
}

// there's a possible go routine scheduling order whereby the stats have not
// been fully updated yet and the following assertions would fail if we
// retrieved stats immediately. the issue rarely happens locally but
// happens with some degree of regularity in CI. we don't have a way
// to ensure stats are updated, so approximating it with a sleep. :|
time.Sleep(10 * time.Millisecond)

stats := r.Stats()

// First verify that metrics with unpredictable values are not zero.
Expand Down

0 comments on commit 809ee76

Please sign in to comment.