Skip to content

Commit

Permalink
Merge pull request #2801 from yue9944882/flaky-ratelimiter-test
Browse files Browse the repository at this point in the history
Fixing flaky rate-limiting test
  • Loading branch information
k8s-ci-robot authored Sep 26, 2023
2 parents 2a84c42 + 0817ff7 commit a344e8c
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ public void testSimpleRateLimitQueue() throws Exception {
long t1 = System.nanoTime();
rlq.addRateLimited("foo");
rlq.get();
long t2 = System.nanoTime();
long t2 = System.nanoTime() - 100000;
long elapsed = t2-t1;
long elapsedMillis = Math.round((float) elapsed / 1000_000f);
long backoffMillis = Math.round((float) MockRateLimiter.mockConstantBackoff.toNanos() / 1000_000f);
assertTrue(
"Unexpected time: " + (t2 - t1) + " vs " + MockRateLimiter.mockConstantBackoff.toNanos(),
t2 - t1 >= MockRateLimiter.mockConstantBackoff.toNanos());
"Unexpected time: " + elapsedMillis + " vs " + backoffMillis,
elapsedMillis >= backoffMillis);
}
}

0 comments on commit a344e8c

Please sign in to comment.