Repository: hbase Updated Branches: refs/heads/branch-1 a189674b4 -> af1f7cf43
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/af1f7cf4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/af1f7cf4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/af1f7cf4 Branch: refs/heads/branch-1 Commit: af1f7cf4314bbf433bf0117f3045a106aee39c80 Parents: a189674 Author: Chia-Ping Tsai <chia7...@gmail.com> Authored: Sun Feb 18 21:22:58 2018 +0800 Committer: Chia-Ping Tsai <chia7...@gmail.com> Committed: Thu Feb 22 09:44:37 2018 +0800 ---------------------------------------------------------------------- .../TestCatalogJanitorInMemoryStates.java | 52 +++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/af1f7cf4/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()); + } + }); } /*