From d51dd933a094bf28ce7db9ef22e187db68f01153 Mon Sep 17 00:00:00 2001 From: Vladimir Rodionov Date: Fri, 7 Sep 2018 17:18:28 -0700 Subject: [PATCH] HBASE-16458: Shorten backup / restore test execution time --- hbase-backup/pom.xml | 5 +++ .../apache/hadoop/hbase/backup/TestBackupBase.java | 40 ++++++++-------------- 2 files changed, 20 insertions(+), 25 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..eab61c85c2 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 @@ -60,11 +60,9 @@ import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.security.HadoopSecurityEnabledUserProviderForTesting; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.security.access.SecureTestUtil; -import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.wal.WALFactory; -import org.junit.AfterClass; import org.junit.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -292,13 +290,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 +310,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 +331,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)