You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2020/06/05 08:02:18 UTC
[hbase] branch branch-2.2 updated: HBASE-24504 refactor call
setupCluster/tearDownCluster in TestTableSnapshotInputFormat (#1851)
This is an automated email from the ASF dual-hosted git repository.
zghao pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.2 by this push:
new 6bde159 HBASE-24504 refactor call setupCluster/tearDownCluster in TestTableSnapshotInputFormat (#1851)
6bde159 is described below
commit 6bde159e10083a9869cf60a74cafb040af526ec0
Author: niuyulin <ny...@163.com>
AuthorDate: Fri Jun 5 14:52:29 2020 +0800
HBASE-24504 refactor call setupCluster/tearDownCluster in TestTableSnapshotInputFormat (#1851)
Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
.../hbase/mapred/TestTableSnapshotInputFormat.java | 8 ++------
.../TableSnapshotInputFormatTestBase.java | 24 +++++++++-------------
.../mapreduce/TestTableSnapshotInputFormat.java | 16 ---------------
3 files changed, 12 insertions(+), 36 deletions(-)
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java
index c591af6..9e05a85 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java
@@ -109,7 +109,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
@Test
public void testInitTableSnapshotMapperJobConfig() throws Exception {
- setupCluster();
final TableName tableName = TableName.valueOf(name.getMethodName());
String snapshotName = "foo";
@@ -134,7 +133,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
- tearDownCluster();
}
}
@@ -176,7 +174,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
protected void testWithMockedMapReduce(HBaseTestingUtility util, String snapshotName,
int numRegions, int numSplitsPerRegion, int expectedNumSplits, boolean setLocalityEnabledTo)
throws Exception {
- setupCluster();
final TableName tableName = TableName.valueOf(name.getMethodName());
try {
createTableAndSnapshot(
@@ -205,7 +202,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
} finally {
util.getAdmin().deleteSnapshot(snapshotName);
util.deleteTable(tableName);
- tearDownCluster();
}
}
@@ -261,8 +257,8 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
@Override
protected void testWithMapReduceImpl(HBaseTestingUtility util, TableName tableName,
- String snapshotName, Path tableDir, int numRegions, int numSplitsPerRegion, int expectedNumSplits,
- boolean shutdownCluster) throws Exception {
+ String snapshotName, Path tableDir, int numRegions, int numSplitsPerRegion,
+ int expectedNumSplits, boolean shutdownCluster) throws Exception {
doTestWithMapReduce(util, tableName, snapshotName, getStartRow(), getEndRow(), tableDir,
numRegions, numSplitsPerRegion, expectedNumSplits, shutdownCluster);
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java
index 95250d2..b7848b8 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormatTestBase.java
@@ -41,7 +41,9 @@ import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,6 +57,7 @@ public abstract class TableSnapshotInputFormatTestBase {
protected FileSystem fs;
protected Path rootDir;
+ @Before
public void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
StartMiniClusterOption option = StartMiniClusterOption.builder()
@@ -65,6 +68,7 @@ public abstract class TableSnapshotInputFormatTestBase {
fs = rootDir.getFileSystem(UTIL.getConfiguration());
}
+ @After
public void tearDownCluster() throws Exception {
UTIL.shutdownMiniCluster();
}
@@ -115,7 +119,6 @@ public abstract class TableSnapshotInputFormatTestBase {
// Test that snapshot restore does not create back references in the HBase root dir.
@Test
public void testRestoreSnapshotDoesNotCreateBackRefLinks() throws Exception {
- setupCluster();
TableName tableName = TableName.valueOf("testRestoreSnapshotDoesNotCreateBackRefLinks");
String snapshotName = "foo";
@@ -149,25 +152,18 @@ public abstract class TableSnapshotInputFormatTestBase {
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
- tearDownCluster();
}
}
public abstract void testRestoreSnapshotDoesNotCreateBackRefLinksInit(TableName tableName,
String snapshotName, Path tmpTableDir) throws Exception;
- protected void testWithMapReduce(HBaseTestingUtility util, String snapshotName,
- int numRegions, int numSplitsPerRegion, int expectedNumSplits, boolean shutdownCluster)
- throws Exception {
- setupCluster();
- try {
- Path tableDir = util.getDataTestDirOnTestFS(snapshotName);
- TableName tableName = TableName.valueOf("testWithMapReduce");
- testWithMapReduceImpl(util, tableName, snapshotName, tableDir, numRegions,
- numSplitsPerRegion, expectedNumSplits, shutdownCluster);
- } finally {
- tearDownCluster();
- }
+ protected void testWithMapReduce(HBaseTestingUtility util, String snapshotName, int numRegions,
+ int numSplitsPerRegion, int expectedNumSplits, boolean shutdownCluster) throws Exception {
+ Path tableDir = util.getDataTestDirOnTestFS(snapshotName);
+ TableName tableName = TableName.valueOf("testWithMapReduce");
+ testWithMapReduceImpl(util, tableName, snapshotName, tableDir, numRegions, numSplitsPerRegion,
+ expectedNumSplits, shutdownCluster);
}
protected static void verifyRowFromMap(ImmutableBytesWritable key, Result result)
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java
index 46d5f3e..58f9632 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableSnapshotInputFormat.java
@@ -54,7 +54,6 @@ import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
-import org.junit.After;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -93,9 +92,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
return yyy;
}
- @After
- public void tearDown() throws Exception {
- }
@Test
public void testGetBestLocations() throws IOException {
@@ -175,7 +171,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
@Test
public void testInitTableSnapshotMapperJobConfig() throws Exception {
- setupCluster();
final TableName tableName = TableName.valueOf(name.getMethodName());
String snapshotName = "foo";
@@ -200,7 +195,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
- tearDownCluster();
}
}
@@ -217,7 +211,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
public void testWithMockedMapReduce(HBaseTestingUtility util, String snapshotName,
int numRegions, int numSplitsPerRegion, int expectedNumSplits, boolean setLocalityEnabledTo)
throws Exception {
- setupCluster();
final TableName tableName = TableName.valueOf(name.getMethodName());
try {
createTableAndSnapshot(
@@ -245,13 +238,11 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
} finally {
util.getAdmin().deleteSnapshot(snapshotName);
util.deleteTable(tableName);
- tearDownCluster();
}
}
@Test
public void testWithMockedMapReduceWithSplitsPerRegion() throws Exception {
- setupCluster();
String snapshotName = "testWithMockedMapReduceMultiRegion";
final TableName tableName = TableName.valueOf(name.getMethodName());
try {
@@ -272,13 +263,11 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
- tearDownCluster();
}
}
@Test
public void testWithMockedMapReduceWithNoStartRowStopRow() throws Exception {
- setupCluster();
String snapshotName = "testWithMockedMapReduceMultiRegion";
final TableName tableName = TableName.valueOf(name.getMethodName());
try {
@@ -301,13 +290,11 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
- tearDownCluster();
}
}
@Test
public void testScanLimit() throws Exception {
- setupCluster();
final TableName tableName = TableName.valueOf(name.getMethodName());
final String snapshotName = tableName + "Snapshot";
Table table = null;
@@ -351,13 +338,11 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
UTIL.getConfiguration().unset(SNAPSHOT_INPUTFORMAT_ROW_LIMIT_PER_INPUTSPLIT);
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
- tearDownCluster();
}
}
@Test
public void testNoDuplicateResultsWhenSplitting() throws Exception {
- setupCluster();
TableName tableName = TableName.valueOf("testNoDuplicateResultsWhenSplitting");
String snapshotName = "testSnapshotBug";
try {
@@ -403,7 +388,6 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
} finally {
UTIL.getAdmin().deleteSnapshot(snapshotName);
UTIL.deleteTable(tableName);
- tearDownCluster();
}
}