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());
|
LOG.info("Starting " + name.getMethodName());
|
||||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||||
|
|
||||||
// Create table and load data.
|
try {
|
||||||
Table table = createTableAndLoadData(MASTER, tableName);
|
// Create table and load data.
|
||||||
// Merge 1st and 2nd region
|
Table table = createTableAndLoadData(MASTER, tableName);
|
||||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1,
|
// Merge 1st and 2nd region
|
||||||
INITIAL_REGION_NUM - 1);
|
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1);
|
||||||
|
|
||||||
// Merge 2nd and 3th region
|
// Merge 2nd and 3th region
|
||||||
PairOfSameType<RegionInfo> mergedRegions =
|
PairOfSameType<RegionInfo> mergedRegions =
|
||||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2,
|
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2);
|
||||||
INITIAL_REGION_NUM - 2);
|
|
||||||
|
|
||||||
verifyRowCount(table, ROWSIZE);
|
verifyRowCount(table, ROWSIZE);
|
||||||
|
|
||||||
// Randomly choose one of the two merged regions
|
// Randomly choose one of the two merged regions
|
||||||
RegionInfo hri = RandomUtils.nextBoolean() ?
|
RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond();
|
||||||
mergedRegions.getFirst() : mergedRegions.getSecond();
|
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
||||||
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
AssignmentManager am = cluster.getMaster().getAssignmentManager();
|
||||||
AssignmentManager am = cluster.getMaster().getAssignmentManager();
|
RegionStates regionStates = am.getRegionStates();
|
||||||
RegionStates regionStates = am.getRegionStates();
|
|
||||||
|
|
||||||
// We should not be able to assign it again
|
// We should not be able to assign it again
|
||||||
am.assign(hri);
|
am.assign(hri);
|
||||||
assertFalse("Merged region can't be assigned",
|
assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri));
|
||||||
regionStates.isRegionInTransition(hri));
|
|
||||||
|
|
||||||
// We should not be able to unassign it either
|
// We should not be able to unassign it either
|
||||||
am.unassign(hri);
|
am.unassign(hri);
|
||||||
assertFalse("Merged region can't be unassigned",
|
assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri));
|
||||||
regionStates.isRegionInTransition(hri));
|
|
||||||
|
|
||||||
table.close();
|
table.close();
|
||||||
|
} finally {
|
||||||
|
TEST_UTIL.deleteTable(tableName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,27 +179,31 @@ public class TestRegionMergeTransactionOnCluster {
|
||||||
public void testMergeAndRestartingMaster() throws Exception {
|
public void testMergeAndRestartingMaster() throws Exception {
|
||||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||||
|
|
||||||
// Create table and load data.
|
|
||||||
Table table = createTableAndLoadData(MASTER, tableName);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MyMasterRpcServices.enabled.set(true);
|
// Create table and load data.
|
||||||
|
Table table = createTableAndLoadData(MASTER, tableName);
|
||||||
|
|
||||||
// Merge 1st and 2nd region
|
try {
|
||||||
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1);
|
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 {
|
} finally {
|
||||||
MyMasterRpcServices.enabled.set(false);
|
TEST_UTIL.deleteTable(tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
table.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCleanMergeReference() throws Exception {
|
public void testCleanMergeReference() throws Exception {
|
||||||
LOG.info("Starting " + name.getMethodName());
|
LOG.info("Starting " + name.getMethodName());
|
||||||
ADMIN.catalogJanitorSwitch(false);
|
ADMIN.catalogJanitorSwitch(false);
|
||||||
|
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||||
try {
|
try {
|
||||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
|
||||||
// Create table and load data.
|
// Create table and load data.
|
||||||
Table table = createTableAndLoadData(MASTER, tableName);
|
Table table = createTableAndLoadData(MASTER, tableName);
|
||||||
// Merge 1st and 2nd region
|
// Merge 1st and 2nd region
|
||||||
|
@ -303,6 +306,7 @@ public class TestRegionMergeTransactionOnCluster {
|
||||||
assertFalse(MetaTableAccessor.hasMergeRegions(mergedRegionResult.rawCells()));
|
assertFalse(MetaTableAccessor.hasMergeRegions(mergedRegionResult.rawCells()));
|
||||||
} finally {
|
} finally {
|
||||||
ADMIN.catalogJanitorSwitch(true);
|
ADMIN.catalogJanitorSwitch(true);
|
||||||
|
TEST_UTIL.deleteTable(tableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,40 +369,39 @@ public class TestRegionMergeTransactionOnCluster {
|
||||||
@Test
|
@Test
|
||||||
public void testMergeWithReplicas() throws Exception {
|
public void testMergeWithReplicas() throws Exception {
|
||||||
final TableName tableName = TableName.valueOf(name.getMethodName());
|
final TableName tableName = TableName.valueOf(name.getMethodName());
|
||||||
// Create table and load data.
|
try {
|
||||||
createTableAndLoadData(MASTER, tableName, 5, 2);
|
// Create table and load data.
|
||||||
List<Pair<RegionInfo, ServerName>> initialRegionToServers =
|
Table table = createTableAndLoadData(MASTER, tableName, 5, 2);
|
||||||
MetaTableAccessor.getTableRegionsAndLocations(
|
List<Pair<RegionInfo, ServerName>> initialRegionToServers =
|
||||||
TEST_UTIL.getConnection(), tableName);
|
MetaTableAccessor.getTableRegionsAndLocations(TEST_UTIL.getConnection(), tableName);
|
||||||
// Merge 1st and 2nd region
|
// Merge 1st and 2nd region
|
||||||
PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName,
|
PairOfSameType<RegionInfo> mergedRegions =
|
||||||
0, 2, 5 * 2 - 2);
|
mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 2, 5 * 2 - 2);
|
||||||
List<Pair<RegionInfo, ServerName>> currentRegionToServers =
|
List<Pair<RegionInfo, ServerName>> currentRegionToServers =
|
||||||
MetaTableAccessor.getTableRegionsAndLocations(
|
MetaTableAccessor.getTableRegionsAndLocations(TEST_UTIL.getConnection(), tableName);
|
||||||
TEST_UTIL.getConnection(), tableName);
|
List<RegionInfo> initialRegions = new ArrayList<>();
|
||||||
List<RegionInfo> initialRegions = new ArrayList<>();
|
for (Pair<RegionInfo, ServerName> p : initialRegionToServers) {
|
||||||
for (Pair<RegionInfo, ServerName> p : initialRegionToServers) {
|
initialRegions.add(p.getFirst());
|
||||||
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(
|
private PairOfSameType<RegionInfo> mergeRegionsAndVerifyRegionNum(
|
||||||
|
|
Loading…
Reference in New Issue