Revert "HBASE-20194 Remove the explicit timeout config for TestTruncateTableProcedure"
This reverts commit cc6fc1f04f
.
This commit is contained in:
parent
ab8d9e736f
commit
f7aca3fa06
|
@ -55,12 +55,12 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos;
|
||||||
|
|
||||||
@Category({ MasterTests.class, MediumTests.class })
|
@Category({MasterTests.class, MediumTests.class})
|
||||||
public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
|
public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static final HBaseClassTestRule CLASS_RULE =
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
HBaseClassTestRule.forClass(TestTruncateTableProcedure.class);
|
HBaseClassTestRule.forClass(TestTruncateTableProcedure.class);
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TestTruncateTableProcedure.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TestTruncateTableProcedure.class);
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
|
||||||
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
|
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testTruncateWithPreserveAfterSplit() throws Exception {
|
public void testTruncateWithPreserveAfterSplit() throws Exception {
|
||||||
String[] families = new String[] { "f1", "f2" };
|
String[] families = new String[] { "f1", "f2" };
|
||||||
byte[][] splitKeys =
|
byte[][] splitKeys =
|
||||||
|
@ -324,10 +324,10 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
|
||||||
TableName tableName = TableName.valueOf(name.getMethodName());
|
TableName tableName = TableName.valueOf(name.getMethodName());
|
||||||
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(getMasterProcedureExecutor(),
|
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(getMasterProcedureExecutor(),
|
||||||
tableName, splitKeys, families);
|
tableName, splitKeys, families);
|
||||||
splitAndTruncate(tableName, regions, 1);
|
splitAndTruncate(tableName, regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testTruncatePreserveWithReplicaRegionAfterSplit() throws Exception {
|
public void testTruncatePreserveWithReplicaRegionAfterSplit() throws Exception {
|
||||||
String[] families = new String[] { "f1", "f2" };
|
String[] families = new String[] { "f1", "f2" };
|
||||||
byte[][] splitKeys =
|
byte[][] splitKeys =
|
||||||
|
@ -335,10 +335,12 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
|
||||||
TableName tableName = TableName.valueOf(name.getMethodName());
|
TableName tableName = TableName.valueOf(name.getMethodName());
|
||||||
|
|
||||||
// create a table with region replications
|
// create a table with region replications
|
||||||
TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName).setRegionReplication(3)
|
TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName)
|
||||||
.setColumnFamilies(Arrays.stream(families)
|
.setRegionReplication(3)
|
||||||
.map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build())
|
.setColumnFamilies(
|
||||||
.collect(Collectors.toList()))
|
Arrays.stream(families)
|
||||||
|
.map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build())
|
||||||
|
.collect(Collectors.toList()))
|
||||||
.build();
|
.build();
|
||||||
RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys);
|
RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys);
|
||||||
ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
|
ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
|
||||||
|
@ -346,17 +348,20 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
|
||||||
new CreateTableProcedure(procExec.getEnvironment(), htd, regions));
|
new CreateTableProcedure(procExec.getEnvironment(), htd, regions));
|
||||||
ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId));
|
ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId));
|
||||||
|
|
||||||
splitAndTruncate(tableName, regions, 3);
|
splitAndTruncate(tableName, regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void splitAndTruncate(TableName tableName, RegionInfo[] regions, int regionReplication)
|
private void splitAndTruncate(TableName tableName, RegionInfo[] regions) throws IOException,
|
||||||
throws IOException, InterruptedException {
|
InterruptedException {
|
||||||
|
|
||||||
// split a region
|
// split a region
|
||||||
UTIL.getAdmin().split(tableName, new byte[] { '0' });
|
UTIL.getAdmin().split(tableName, new byte[]{'0'});
|
||||||
|
UTIL.waitUntilAllRegionsAssigned(tableName);
|
||||||
|
|
||||||
// wait until split really happens
|
// wait until split really happens
|
||||||
UTIL.waitFor(60000,
|
while (UTIL.getAdmin().getRegions(tableName).size() <= regions.length) {
|
||||||
() -> UTIL.getAdmin().getRegions(tableName).size() > regions.length * regionReplication);
|
Thread.sleep(50);
|
||||||
|
}
|
||||||
|
|
||||||
// disable the table
|
// disable the table
|
||||||
UTIL.getAdmin().disableTable(tableName);
|
UTIL.getAdmin().disableTable(tableName);
|
||||||
|
@ -368,8 +373,5 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
|
||||||
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
|
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
|
||||||
|
|
||||||
UTIL.waitUntilAllRegionsAssigned(tableName);
|
UTIL.waitUntilAllRegionsAssigned(tableName);
|
||||||
// confirm that we have the correct number of regions
|
|
||||||
assertEquals((regions.length + 1) * regionReplication,
|
|
||||||
UTIL.getAdmin().getRegions(tableName).size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue