You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bu...@apache.org on 2018/08/22 16:31:34 UTC
[3/3] hbase git commit: HBASE-21094 Remove the explicit timeout
config for TestTruncateTableProcedure
HBASE-21094 Remove the explicit timeout config for TestTruncateTableProcedure
(cherry picked from commit 74ea0111696e2a01a478fd7e11cfad14d1bfc3b5)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b0af08bf
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b0af08bf
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b0af08bf
Branch: refs/heads/master
Commit: b0af08bf9bebffdc20e14f28e216b55f298254a7
Parents: 899982c
Author: Duo Zhang <zh...@apache.org>
Authored: Wed Aug 22 11:29:23 2018 +0800
Committer: Sean Busbey <bu...@apache.org>
Committed: Wed Aug 22 11:30:05 2018 -0500
----------------------------------------------------------------------
.../procedure/TestTruncateTableProcedure.java | 37 ++++++++++----------
1 file changed, 18 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/b0af08bf/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java
index ea6ee0e..5b38b17 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java
@@ -55,12 +55,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos;
-@Category({MasterTests.class, MediumTests.class})
+@Category({ MasterTests.class, MediumTests.class })
public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestTruncateTableProcedure.class);
+ HBaseClassTestRule.forClass(TestTruncateTableProcedure.class);
private static final Logger LOG = LoggerFactory.getLogger(TestTruncateTableProcedure.class);
@@ -316,7 +316,7 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
}
- @Test(timeout = 60000)
+ @Test
public void testTruncateWithPreserveAfterSplit() throws Exception {
String[] families = new String[] { "f1", "f2" };
byte[][] splitKeys =
@@ -324,10 +324,10 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
TableName tableName = TableName.valueOf(name.getMethodName());
RegionInfo[] regions = MasterProcedureTestingUtility.createTable(getMasterProcedureExecutor(),
tableName, splitKeys, families);
- splitAndTruncate(tableName, regions);
+ splitAndTruncate(tableName, regions, 1);
}
- @Test(timeout = 60000)
+ @Test
public void testTruncatePreserveWithReplicaRegionAfterSplit() throws Exception {
String[] families = new String[] { "f1", "f2" };
byte[][] splitKeys =
@@ -335,12 +335,10 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
TableName tableName = TableName.valueOf(name.getMethodName());
// create a table with region replications
- TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName)
- .setRegionReplication(3)
- .setColumnFamilies(
- Arrays.stream(families)
- .map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build())
- .collect(Collectors.toList()))
+ TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName).setRegionReplication(3)
+ .setColumnFamilies(Arrays.stream(families)
+ .map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build())
+ .collect(Collectors.toList()))
.build();
RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys);
ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
@@ -348,20 +346,18 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
new CreateTableProcedure(procExec.getEnvironment(), htd, regions));
ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId));
- splitAndTruncate(tableName, regions);
+ splitAndTruncate(tableName, regions, 3);
}
- private void splitAndTruncate(TableName tableName, RegionInfo[] regions) throws IOException,
- InterruptedException {
-
+ private void splitAndTruncate(TableName tableName, RegionInfo[] regions, int regionReplication)
+ throws IOException, InterruptedException {
// 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
- while (UTIL.getAdmin().getRegions(tableName).size() <= regions.length) {
- Thread.sleep(50);
- }
+ UTIL.waitFor(60000,
+ () -> UTIL.getAdmin().getRegions(tableName).size() > regions.length * regionReplication);
// disable the table
UTIL.getAdmin().disableTable(tableName);
@@ -373,5 +369,8 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
UTIL.waitUntilAllRegionsAssigned(tableName);
+ // confirm that we have the correct number of regions
+ assertEquals((regions.length + 1) * regionReplication,
+ UTIL.getAdmin().getRegions(tableName).size());
}
}