You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ch...@apache.org on 2018/02/22 01:42:43 UTC

hbase git commit: HBASE-20016 TestCatalogJanitorInMemoryStates#testInMemoryForReplicaParentCleanup is flaky

Repository: hbase
Updated Branches:
  refs/heads/branch-1.4 a01323b2c -> 08b993997


HBASE-20016 TestCatalogJanitorInMemoryStates#testInMemoryForReplicaParentCleanup is flaky


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

Branch: refs/heads/branch-1.4
Commit: 08b993997404aad7ec8f66b8c2b2083062c9ef1a
Parents: a01323b
Author: Chia-Ping Tsai <ch...@gmail.com>
Authored: Sun Feb 18 21:22:58 2018 +0800
Committer: Chia-Ping Tsai <ch...@gmail.com>
Committed: Thu Feb 22 09:15:54 2018 +0800

----------------------------------------------------------------------
 .../TestCatalogJanitorInMemoryStates.java       | 52 +++++++++-----------
 1 file changed, 22 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/08b99399/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorInMemoryStates.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorInMemoryStates.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorInMemoryStates.java
index 5ec3d6a..301ff6b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorInMemoryStates.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorInMemoryStates.java
@@ -124,7 +124,7 @@ public class TestCatalogJanitorInMemoryStates {
    * AM's serverHoldings and
    */
   @Test(timeout = 180000)
-  public void testInMemoryForReplicaParentCleanup() throws IOException, InterruptedException {
+  public void testInMemoryForReplicaParentCleanup() throws Exception {
     final AssignmentManager am = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
     final CatalogJanitor janitor = TEST_UTIL.getHBaseCluster().getMaster().catalogJanitorChore;
 
@@ -139,35 +139,27 @@ public class TestCatalogJanitorInMemoryStates {
     // There are two regions, one for primary, one for the replica.
     assertTrue(allRegionLocations.size() == 2);
 
-    HRegionLocation replicaParentRegion, primaryParentRegion;
-    if (RegionReplicaUtil.isDefaultReplica(
-        allRegionLocations.get(0).getRegionInfo().getReplicaId())) {
-      primaryParentRegion = allRegionLocations.get(0);
-      replicaParentRegion = allRegionLocations.get(1);
-    } else {
-      primaryParentRegion = allRegionLocations.get(1);
-      replicaParentRegion = allRegionLocations.get(0);
-    }
-
-    List<HRegionLocation> primaryDaughters = splitRegion(primaryParentRegion.getRegionInfo(),
-        Bytes.toBytes("a"));
-
-    // Wait until the replica parent region is offline.
-    while (am.getRegionStates().isRegionOnline(replicaParentRegion.getRegionInfo())) {
-      Thread.sleep(100);
-    }
-
-    assertNotNull("Should have found daughter regions for " + primaryDaughters, primaryDaughters);
-
-    // check that primary parent region is not in AM's serverHoldings
-    assertFalse("Primary Parent region should have been removed from RegionState's serverHoldings",
-        am.getRegionStates().existsInServerHoldings(primaryParentRegion.getServerName(),
-            primaryParentRegion.getRegionInfo()));
-
-    // check that primary parent region is not in AM's serverHoldings
-    assertFalse("Primary Parent region should have been removed from RegionState's serverHoldings",
-        am.getRegionStates().existsInServerHoldings(replicaParentRegion.getServerName(),
-            replicaParentRegion.getRegionInfo()));
+    final HRegionLocation primaryParentRegion
+      = RegionReplicaUtil.isDefaultReplica(
+      allRegionLocations.get(0).getRegionInfo().getReplicaId()) ? allRegionLocations.get(0)
+        : allRegionLocations.get(1);
+    final HRegionLocation replicaParentRegion
+      = RegionReplicaUtil.isDefaultReplica(
+      allRegionLocations.get(0).getRegionInfo().getReplicaId()) ? allRegionLocations.get(1)
+      : allRegionLocations.get(0);
+
+    assertNotNull("Should have found daughter regions for " + primaryParentRegion,
+      splitRegion(primaryParentRegion.getRegionInfo(), Bytes.toBytes("a")));
+
+    TEST_UTIL.waitFor(60 * 1000, new Waiter.Predicate<Exception>() {
+      @Override
+      public boolean evaluate() throws Exception {
+        return !am.getRegionStates().existsInServerHoldings(primaryParentRegion.getServerName(),
+          primaryParentRegion.getRegionInfo()) &&
+          !am.getRegionStates().existsInServerHoldings(replicaParentRegion.getServerName(),
+            replicaParentRegion.getRegionInfo());
+      }
+    });
   }
 
   /*