Commit fb256b29 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #39628 from deads2k/fix-throttle

Automatic merge from submit-queue (batch tested with PRs 39628, 39551, 38746, 38352, 39607) fix throttling test Fixes https://github.com/kubernetes/kubernetes/issues/39285. The token bucket starts full, so getting 100 tokens doesn't take a full second, right? Getting 101 tokens does take a full second. @liggitt looks like your test.
parents 3683e0a6 e10d4cbd
...@@ -64,7 +64,8 @@ func TestMultithreadedThrottling(t *testing.T) { ...@@ -64,7 +64,8 @@ func TestMultithreadedThrottling(t *testing.T) {
// record wall time // record wall time
endTime := time.Now() endTime := time.Now()
if duration := endTime.Sub(startTime); duration < time.Second { // tolerate a 1% clock change because these things happen
if duration := endTime.Sub(startTime); duration < (time.Second * 99 / 100) {
// We shouldn't be able to get 100 tokens out of the bucket in less than 1 second of wall clock time, no matter what // We shouldn't be able to get 100 tokens out of the bucket in less than 1 second of wall clock time, no matter what
t.Errorf("Expected it to take at least 1 second to get 100 tokens, took %v", duration) t.Errorf("Expected it to take at least 1 second to get 100 tokens, took %v", duration)
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment