HBASE-20016 TestCatalogJanitorInMemoryStates#testInMemoryForReplicaParentCleanup is flaky

This commit is contained in:
Chia-Ping Tsai 2018-02-18 21:22:58 +08:00
parent a189674b4c
commit af1f7cf431

View File

@ -124,7 +124,7 @@ public class TestCatalogJanitorInMemoryStates {
* AM's serverHoldings and * AM's serverHoldings and
*/ */
@Test(timeout = 180000) @Test(timeout = 180000)
public void testInMemoryForReplicaParentCleanup() throws IOException, InterruptedException { public void testInMemoryForReplicaParentCleanup() throws Exception {
final AssignmentManager am = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager(); final AssignmentManager am = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
final CatalogJanitor janitor = TEST_UTIL.getHBaseCluster().getMaster().catalogJanitorChore; 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. // There are two regions, one for primary, one for the replica.
assertTrue(allRegionLocations.size() == 2); assertTrue(allRegionLocations.size() == 2);
HRegionLocation replicaParentRegion, primaryParentRegion; final HRegionLocation primaryParentRegion
if (RegionReplicaUtil.isDefaultReplica( = RegionReplicaUtil.isDefaultReplica(
allRegionLocations.get(0).getRegionInfo().getReplicaId())) { allRegionLocations.get(0).getRegionInfo().getReplicaId()) ? allRegionLocations.get(0)
primaryParentRegion = allRegionLocations.get(0); : allRegionLocations.get(1);
replicaParentRegion = allRegionLocations.get(1); final HRegionLocation replicaParentRegion
} else { = RegionReplicaUtil.isDefaultReplica(
primaryParentRegion = allRegionLocations.get(1); allRegionLocations.get(0).getRegionInfo().getReplicaId()) ? allRegionLocations.get(1)
replicaParentRegion = allRegionLocations.get(0); : allRegionLocations.get(0);
}
List<HRegionLocation> primaryDaughters = splitRegion(primaryParentRegion.getRegionInfo(), assertNotNull("Should have found daughter regions for " + primaryParentRegion,
Bytes.toBytes("a")); splitRegion(primaryParentRegion.getRegionInfo(), Bytes.toBytes("a")));
// Wait until the replica parent region is offline. TEST_UTIL.waitFor(60 * 1000, new Waiter.Predicate<Exception>() {
while (am.getRegionStates().isRegionOnline(replicaParentRegion.getRegionInfo())) { @Override
Thread.sleep(100); public boolean evaluate() throws Exception {
} return !am.getRegionStates().existsInServerHoldings(primaryParentRegion.getServerName(),
primaryParentRegion.getRegionInfo()) &&
assertNotNull("Should have found daughter regions for " + primaryDaughters, primaryDaughters); !am.getRegionStates().existsInServerHoldings(replicaParentRegion.getServerName(),
replicaParentRegion.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(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()));
} }
/* /*