mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
retry: relax timing for test a bit
This commit is contained in:
parent
406dc2ead8
commit
3aa752e998
@ -6,15 +6,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// delta defines the time band a test run should complete in.
|
// delta defines the time band a test run should complete in.
|
||||||
var delta = 10 * time.Millisecond
|
var delta = 25 * time.Millisecond
|
||||||
|
|
||||||
func TestRetryer(t *testing.T) {
|
func TestRetryer(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
desc string
|
desc string
|
||||||
r Retryer
|
r Retryer
|
||||||
}{
|
}{
|
||||||
{"counter", &Counter{Count: 3, Wait: 10 * time.Millisecond}},
|
{"counter", &Counter{Count: 3, Wait: 100 * time.Millisecond}},
|
||||||
{"timer", &Timer{Timeout: 20 * time.Millisecond, Wait: 10 * time.Millisecond}},
|
{"timer", &Timer{Timeout: 200 * time.Millisecond, Wait: 100 * time.Millisecond}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -35,7 +35,7 @@ func TestRetryer(t *testing.T) {
|
|||||||
// since the first iteration happens immediately
|
// since the first iteration happens immediately
|
||||||
// the retryer waits only twice for three iterations.
|
// the retryer waits only twice for three iterations.
|
||||||
// order of events: (true, (wait) true, (wait) true, false)
|
// order of events: (true, (wait) true, (wait) true, false)
|
||||||
if got, want := dur, 20*time.Millisecond; got < (want-delta) || got > (want+delta) {
|
if got, want := dur, 200*time.Millisecond; got < (want-delta) || got > (want+delta) {
|
||||||
t.Fatalf("loop took %v want %v (+/- %v)", got, want, delta)
|
t.Fatalf("loop took %v want %v (+/- %v)", got, want, delta)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user