HBASE-24504 refactor call setupCluster/tearDownCluster in TestTableSnapshotInputFormat (#1851)
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
b2ec4c1ea0
commit
9cc3b79d5f
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,9 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||
import org.apache.hadoop.hbase.util.CommonFSUtils;
|
||||
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;
|
||||
|
@ -56,6 +58,7 @@ public abstract class TableSnapshotInputFormatTestBase {
|
|||
protected FileSystem fs;
|
||||
protected Path rootDir;
|
||||
|
||||
@Before
|
||||
public void setupCluster() throws Exception {
|
||||
setupConf(UTIL.getConfiguration());
|
||||
StartMiniClusterOption option = StartMiniClusterOption.builder()
|
||||
|
@ -66,6 +69,7 @@ public abstract class TableSnapshotInputFormatTestBase {
|
|||
fs = rootDir.getFileSystem(UTIL.getConfiguration());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDownCluster() throws Exception {
|
||||
UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
@ -116,7 +120,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";
|
||||
|
||||
|
@ -151,25 +154,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)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue