uber / ringpop-go

Scalable, fault-tolerant application-layer sharding for Go applications
http://www.uber.com
MIT License
835 stars 83 forks source link

Fix Flappy Stats Test #164

Closed thanodnl closed 8 years ago

thanodnl commented 8 years ago

This PR is in the hope to fix a flappy test that happens more often than not:

--- FAIL: TestProtocolStats (5.09s)
    Error Trace:    stats_test.go:89
    Error:      Should not be zero, but was 0

    Error Trace:    stats_test.go:90
    Error:      Should not be zero, but was 0

--- FAIL: TestStatsTestSuite (5.21s)
FAIL
FAIL    github.com/uber/ringpop-go/swim 9.984s

The reasoning behind the change is that metrics.Meter mentioned in the comments above is snapshotted every 5 seconds and made available to read from. By exactly waiting 5 seconds we might still read the values just before the snapshot is actually populated with information. By waiting an additional second the hope is that we read less 0's.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 94.668% when pulling a492b9a2d3efd5ceaed068ff26c301ee218417cc on test/flappy-stats-test into 19ff2e65a88aa24bab0e490ee355972d70d8f7bb on dev.

thanodnl commented 8 years ago

Ran the unit tests on travis 6 times without any flap on the changed test.

mennopruijssers commented 8 years ago

LGTM. it's sad though that we can't inject a different time in the meter library.

motiejus commented 8 years ago

LGTM

The LGTM is in alt-text.

dansimau commented 8 years ago

I think we can optimise this

time.Sleep(5100*time.Millisecond)