Browse Source

Make WarmUpRateLimiterControllerTest stable

master
jason Eric Zhao 5 years ago
parent
commit
16082a875c
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/block/flow/controller/WarmUpRateLimiterControllerTest.java

+ 7
- 3
sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/block/flow/controller/WarmUpRateLimiterControllerTest.java View File

@@ -27,10 +27,14 @@ public class WarmUpRateLimiterControllerTest {

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


Loading…
Cancel
Save