diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-04-26 17:49:28 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-04-27 19:37:31 +0000 |
commit | 13e87cda000149ff3efce95210b0c921f7d772bf (patch) | |
tree | a24bfb09e020bae943e6846acc390e4668f71be3 /src/time | |
parent | f432d3fc41b8f6b01131023aabcf935ebea172cb (diff) | |
download | go-13e87cda000149ff3efce95210b0c921f7d772bf.tar.gz go-13e87cda000149ff3efce95210b0c921f7d772bf.zip |
time: increase slop for TestTicker
Also sleep a bit each time it fails, in case the system is overloaded.
Fixes #37332
Change-Id: Iabf3d0a27b5834c1e2a87c826b6206146b4f62c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/313849
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/time')
-rw-r--r-- | src/time/tick_test.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/time/tick_test.go b/src/time/tick_test.go index 9a1cdf9ab2..b5d0a189bc 100644 --- a/src/time/tick_test.go +++ b/src/time/tick_test.go @@ -52,9 +52,14 @@ func TestTicker(t *testing.T) { t1 := Now() dt := t1.Sub(t0) target := 3 * delta * Duration(count/2) - slop := target * 2 / 10 + slop := target * 3 / 10 if dt < target-slop || dt > target+slop { - errs = append(errs, fmt.Sprintf("%d %s ticks took %s, expected [%s,%s]", count, delta, dt, target-slop, target+slop)) + errs = append(errs, fmt.Sprintf("%d %s ticks then %d %s ticks took %s, expected [%s,%s]", count/2, delta, count/2, delta*2, dt, target-slop, target+slop)) + if dt > target+slop { + // System may be overloaded; sleep a bit + // in the hopes it will recover. + Sleep(Second / 2) + } continue } // Now test that the ticker stopped. |