Skip to content

Commit

Permalink
Make WarmUpRateLimiterControllerTest stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonjoo2010 authored and sczyh30 committed Apr 12, 2019
1 parent aaeeea3 commit 16082a8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public void testPace() throws InterruptedException {

assertTrue(controller.canPass(node, 1));

// Easily fail in single request testing, so we increase it to 10 requests and test the average time
long start = System.currentTimeMillis();
assertTrue(controller.canPass(node, 1));
long cost = System.currentTimeMillis() - start;
assertTrue(cost >= 100 && cost <= 120);
int requests = 10;
for (int i = 0; i < requests; i++) {
assertTrue(controller.canPass(node, 1));
}
float cost = (System.currentTimeMillis() - start) / 1.0f / requests;
assertTrue(Math.abs(cost - 100) < 10);
}

@Test
Expand Down

0 comments on commit 16082a8

Please sign in to comment.