add fixes for flaky tests (#5146)

While working on tendermint my colleague @jinmannwong fixed a few of the unit tests that we found to be flaky in our CI. We thought that you might find this useful, see below for comments.
This commit is contained in:
n-hutton
2020-07-27 07:36:56 +01:00
committed by GitHub
parent 940e68292c
commit 375f0c819f
4 changed files with 38 additions and 28 deletions

View File

@@ -67,14 +67,16 @@ func TestThrottle(test *testing.T) {
time.Sleep(longwait)
assert.Equal(2, c.Count())
// send 12, over 2 delay sections, adds 3
// send 12, over 2 delay sections, adds 3 or more. It
// is possible for more to be added if the overhead
// in executing the loop is large
short := time.Duration(ms/5) * time.Millisecond
for i := 0; i < 13; i++ {
t.Set()
time.Sleep(short)
}
time.Sleep(longwait)
assert.Equal(5, c.Count())
assert.LessOrEqual(5, c.Count())
close(t.Ch)
}