hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject [03/38] hbase git commit: HBASE-19490 Rare failure in TestRateLimiter
Date Thu, 04 Jan 2018 08:19:37 GMT
HBASE-19490 Rare failure in TestRateLimiter


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/338a74e7
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/338a74e7
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/338a74e7

Branch: refs/heads/HBASE-19397
Commit: 338a74e73705fd7c80111ade47345b2a6efe11e7
Parents: 3010625
Author: Chia-Ping Tsai <chia7712@gmail.com>
Authored: Wed Jan 3 03:19:07 2018 +0800
Committer: Chia-Ping Tsai <chia7712@gmail.com>
Committed: Thu Jan 4 10:46:43 2018 +0800

----------------------------------------------------------------------
 .../apache/hadoop/hbase/quotas/TestRateLimiter.java  | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/338a74e7/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
index e205f9b..567577b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java
@@ -23,10 +23,10 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.concurrent.TimeUnit;
-
-import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.testclassification.RegionServerTests;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.util.EnvironmentEdge;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -122,6 +122,16 @@ public class TestRateLimiter {
     RateLimiter limiter = new FixedIntervalRateLimiter();
     limiter.set(10, TimeUnit.SECONDS);
 
+    // fix the current time in order to get the precise value of interval
+    EnvironmentEdge edge = new EnvironmentEdge() {
+      private final long ts = System.currentTimeMillis();
+
+      @Override
+      public long currentTime() {
+        return ts;
+      }
+    };
+    EnvironmentEdgeManager.injectEdge(edge);
     // 10 resources are available, but we need to consume 20 resources
     // Verify that we have to wait at least 1.1sec to have 1 resource available
     assertTrue(limiter.canExecute());
@@ -130,6 +140,7 @@ public class TestRateLimiter {
     assertEquals(1000, limiter.waitInterval(1));
     // To consume 10 resource wait for 100ms
     assertEquals(1000, limiter.waitInterval(10));
+    EnvironmentEdgeManager.reset();
 
     limiter.setNextRefillTime(limiter.getNextRefillTime() - 900);
     // Verify that after 1sec also no resource should be available


Mime
View raw message