From 0cb7f2e62597c8fa0eab930e37e63ed38c7f6f29 Mon Sep 17 00:00:00 2001 From: Vladimir Rodionov Date: Fri, 7 Sep 2018 14:43:29 -0700 Subject: [PATCH] HBASE-16458: Shorten backup / restore test execution time --- hbase-backup/pom.xml | 5 +++ .../apache/hadoop/hbase/backup/TestBackupBase.java | 39 +++++++++------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/hbase-backup/pom.xml b/hbase-backup/pom.xml index 00a996f51e..3f2e5887ab 100644 --- a/hbase-backup/pom.xml +++ b/hbase-backup/pom.xml @@ -65,6 +65,11 @@ + + 4 + 4 + 2 + diff --git a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java index 08ecd632c6..d7c4fbb47f 100644 --- a/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java +++ b/hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java @@ -66,6 +66,7 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.wal.WALFactory; import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -292,13 +293,8 @@ public class TestBackupBase { conf1.set(WALFactory.WAL_PROVIDER, provider); TEST_UTIL.startMiniCluster(); - if (useSecondCluster) { - conf2 = HBaseConfiguration.create(conf1); - conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2"); - TEST_UTIL2 = new HBaseTestingUtility(conf2); - TEST_UTIL2.setZkCluster(TEST_UTIL.getZkCluster()); - TEST_UTIL2.startMiniCluster(); - } + checkSecondCluster(); + conf1 = TEST_UTIL.getConfiguration(); TEST_UTIL.startMiniMapReduceCluster(); @@ -317,6 +313,19 @@ public class TestBackupBase { setupIsDone = true; } + private void checkSecondCluster() throws Exception { + if (useSecondCluster) { + if (TEST_UTIL2 != null) { + return; + } + conf2 = HBaseConfiguration.create(conf1); + conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2"); + TEST_UTIL2 = new HBaseTestingUtility(conf2); + TEST_UTIL2.setZkCluster(TEST_UTIL.getZkCluster()); + TEST_UTIL2.startMiniCluster(); + } + } + private static void populateFromMasterConfig(Configuration masterConf, Configuration conf) { Iterator> it = masterConf.iterator(); while (it.hasNext()) { @@ -325,22 +334,6 @@ public class TestBackupBase { } } - /** - * @throws Exception if deleting the archive directory or shutting down the mini cluster fails - */ - @AfterClass - public static void tearDown() throws Exception { - try{ - SnapshotTestingUtils.deleteAllSnapshots(TEST_UTIL.getHBaseAdmin()); - } catch (Exception e) { - } - SnapshotTestingUtils.deleteArchiveDirectory(TEST_UTIL); - if (useSecondCluster) { - TEST_UTIL2.shutdownMiniCluster(); - } - TEST_UTIL.shutdownMiniCluster(); - TEST_UTIL.shutdownMiniMapReduceCluster(); - } HTable insertIntoTable(Connection conn, TableName table, byte[] family, int id, int numRows) throws IOException { -- 2.14.3 (Apple Git-98)