test: fix the TestRetryUntil (#14210)

Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
He Weiwei 2021-02-09 13:25:22 +08:00 committed by GitHub
parent 0b2ef922c0
commit a0561da5ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,7 +31,10 @@ func TestRetryUntil(t *testing.T) {
return fmt.Errorf("failed")
}
assert.Error(RetryUntil(f1, RetryInitialInterval(time.Second), RetryMaxInterval(time.Second), RetryTimeout(time.Second*5)))
assert.LessOrEqual(i, 5)
// f1 called time 0s - sleep - 1s - sleep - 2s - sleep - 3s - sleep - 4s - sleep - 5s
// i after f1 called 1 2 3 4 5 6
// the i may be 5 or 6 depend on timeout or default which is seleted by the select statement
assert.LessOrEqual(i, 6)
f2 := func() error {
return nil