HBASE-24159 [flakey test] regionserver.TestRegionMergeTransactionOnCluster (#1472)
Delete tables after each test cases to avoid polluting states. Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
b4af0a0943
commit
8aa3304427
|
@ -139,37 +139,36 @@ public class TestRegionMergeTransactionOnCluster {
|
|||
LOG.info("Starting " + name.getMethodName());
|
||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||
|
||||
// Create table and load data.
|
||||
Table table = createTableAndLoadData(MASTER, tableName);
|
||||
// Merge 1st and 2nd region
|
||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1,
|
||||
INITIAL_REGION_NUM - 1);
|
||||
try {
|
||||
// Create table and load data.
|
||||
Table table = createTableAndLoadData(MASTER, tableName);
|
||||
// Merge 1st and 2nd region
|
||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1);
|
||||
|
||||
// Merge 2nd and 3th region
|
||||
PairOfSameType<RegionInfo> mergedRegions =
|
||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2,
|
||||
INITIAL_REGION_NUM - 2);
|
||||
// Merge 2nd and 3th region
|
||||
PairOfSameType<RegionInfo> mergedRegions =
|
||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2);
|
||||
|
||||
verifyRowCount(table, ROWSIZE);
|
||||
verifyRowCount(table, ROWSIZE);
|
||||
|
||||
// Randomly choose one of the two merged regions
|
||||
RegionInfo hri = RandomUtils.nextBoolean() ?
|
||||
mergedRegions.getFirst() : mergedRegions.getSecond();
|
||||
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
||||
AssignmentManager am = cluster.getMaster().getAssignmentManager();
|
||||
RegionStates regionStates = am.getRegionStates();
|
||||
// Randomly choose one of the two merged regions
|
||||
RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond();
|
||||
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
||||
AssignmentManager am = cluster.getMaster().getAssignmentManager();
|
||||
RegionStates regionStates = am.getRegionStates();
|
||||
|
||||
// We should not be able to assign it again
|
||||
am.assign(hri);
|
||||
assertFalse("Merged region can't be assigned",
|
||||
regionStates.isRegionInTransition(hri));
|
||||
// We should not be able to assign it again
|
||||
am.assign(hri);
|
||||
assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri));
|
||||
|
||||
// We should not be able to unassign it either
|
||||
am.unassign(hri);
|
||||
assertFalse("Merged region can't be unassigned",
|
||||
regionStates.isRegionInTransition(hri));
|
||||
// We should not be able to unassign it either
|
||||
am.unassign(hri);
|
||||
assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri));
|
||||
|
||||
table.close();
|
||||
table.close();
|
||||
} finally {
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,27 +179,31 @@ public class TestRegionMergeTransactionOnCluster {
|
|||
public void testMergeAndRestartingMaster() throws Exception {
|
||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||
|
||||
// Create table and load data.
|
||||
Table table = createTableAndLoadData(MASTER, tableName);
|
||||
|
||||
try {
|
||||
MyMasterRpcServices.enabled.set(true);
|
||||
// Create table and load data.
|
||||
Table table = createTableAndLoadData(MASTER, tableName);
|
||||
|
||||
// Merge 1st and 2nd region
|
||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1);
|
||||
try {
|
||||
MyMasterRpcServices.enabled.set(true);
|
||||
|
||||
// Merge 1st and 2nd region
|
||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1);
|
||||
} finally {
|
||||
MyMasterRpcServices.enabled.set(false);
|
||||
}
|
||||
|
||||
table.close();
|
||||
} finally {
|
||||
MyMasterRpcServices.enabled.set(false);
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
}
|
||||
|
||||
table.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCleanMergeReference() throws Exception {
|
||||
LOG.info("Starting " + name.getMethodName());
|
||||
ADMIN.catalogJanitorSwitch(false);
|
||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||
try {
|
||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||
// Create table and load data.
|
||||
Table table = createTableAndLoadData(MASTER, tableName);
|
||||
// Merge 1st and 2nd region
|
||||
|
@ -303,6 +306,7 @@ public class TestRegionMergeTransactionOnCluster {
|
|||
assertFalse(MetaTableAccessor.hasMergeRegions(mergedRegionResult.rawCells()));
|
||||
} finally {
|
||||
ADMIN.catalogJanitorSwitch(true);
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,40 +369,39 @@ public class TestRegionMergeTransactionOnCluster {
|
|||
@Test
|
||||
public void testMergeWithReplicas() throws Exception {
|
||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||
// Create table and load data.
|
||||
createTableAndLoadData(MASTER, tableName, 5, 2);
|
||||
List<Pair<RegionInfo, ServerName>> initialRegionToServers =
|
||||
MetaTableAccessor.getTableRegionsAndLocations(
|
||||
TEST_UTIL.getConnection(), tableName);
|
||||
// Merge 1st and 2nd region
|
||||
PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName,
|
||||
0, 2, 5 * 2 - 2);
|
||||
List<Pair<RegionInfo, ServerName>> currentRegionToServers =
|
||||
MetaTableAccessor.getTableRegionsAndLocations(
|
||||
TEST_UTIL.getConnection(), tableName);
|
||||
List<RegionInfo> initialRegions = new ArrayList<>();
|
||||
for (Pair<RegionInfo, ServerName> p : initialRegionToServers) {
|
||||
initialRegions.add(p.getFirst());
|
||||
try {
|
||||
// Create table and load data.
|
||||
Table table = createTableAndLoadData(MASTER, tableName, 5, 2);
|
||||
List<Pair<RegionInfo, ServerName>> initialRegionToServers =
|
||||
MetaTableAccessor.getTableRegionsAndLocations(TEST_UTIL.getConnection(), tableName);
|
||||
// Merge 1st and 2nd region
|
||||
PairOfSameType<RegionInfo> mergedRegions =
|
||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 2, 5 * 2 - 2);
|
||||
List<Pair<RegionInfo, ServerName>> currentRegionToServers =
|
||||
MetaTableAccessor.getTableRegionsAndLocations(TEST_UTIL.getConnection(), tableName);
|
||||
List<RegionInfo> initialRegions = new ArrayList<>();
|
||||
for (Pair<RegionInfo, ServerName> p : initialRegionToServers) {
|
||||
initialRegions.add(p.getFirst());
|
||||
}
|
||||
List<RegionInfo> currentRegions = new ArrayList<>();
|
||||
for (Pair<RegionInfo, ServerName> p : currentRegionToServers) {
|
||||
currentRegions.add(p.getFirst());
|
||||
}
|
||||
assertTrue(initialRegions.contains(mergedRegions.getFirst())); //this is the first region
|
||||
assertTrue(initialRegions.contains(RegionReplicaUtil
|
||||
.getRegionInfoForReplica(mergedRegions.getFirst(), 1))); //this is the replica of the first region
|
||||
assertTrue(initialRegions.contains(mergedRegions.getSecond())); //this is the second region
|
||||
assertTrue(initialRegions.contains(RegionReplicaUtil
|
||||
.getRegionInfoForReplica(mergedRegions.getSecond(), 1))); //this is the replica of the second region
|
||||
assertTrue(!initialRegions.contains(currentRegions.get(0))); //this is the new region
|
||||
assertTrue(!initialRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(currentRegions.get(0), 1))); //replica of the new region
|
||||
assertTrue(currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(currentRegions.get(0), 1))); //replica of the new region
|
||||
assertTrue(!currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(mergedRegions.getFirst(), 1))); //replica of the merged region
|
||||
assertTrue(!currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(mergedRegions.getSecond(), 1))); //replica of the merged region
|
||||
table.close();
|
||||
} finally {
|
||||
TEST_UTIL.deleteTable(tableName);
|
||||
}
|
||||
List<RegionInfo> currentRegions = new ArrayList<>();
|
||||
for (Pair<RegionInfo, ServerName> p : currentRegionToServers) {
|
||||
currentRegions.add(p.getFirst());
|
||||
}
|
||||
assertTrue(initialRegions.contains(mergedRegions.getFirst())); //this is the first region
|
||||
assertTrue(initialRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(
|
||||
mergedRegions.getFirst(), 1))); //this is the replica of the first region
|
||||
assertTrue(initialRegions.contains(mergedRegions.getSecond())); //this is the second region
|
||||
assertTrue(initialRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(
|
||||
mergedRegions.getSecond(), 1))); //this is the replica of the second region
|
||||
assertTrue(!initialRegions.contains(currentRegions.get(0))); //this is the new region
|
||||
assertTrue(!initialRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(
|
||||
currentRegions.get(0), 1))); //replica of the new region
|
||||
assertTrue(currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(
|
||||
currentRegions.get(0), 1))); //replica of the new region
|
||||
assertTrue(!currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(
|
||||
mergedRegions.getFirst(), 1))); //replica of the merged region
|
||||
assertTrue(!currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica(
|
||||
mergedRegions.getSecond(), 1))); //replica of the merged region
|
||||
}
|
||||
|
||||
private PairOfSameType<RegionInfo> mergeRegionsAndVerifyRegionNum(
|
||||
|
|
Loading…
Reference in New Issue