You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by re...@apache.org on 2020/09/30 10:56:02 UTC

[hbase] branch branch-1 updated: HBASE-25122 [Flake Test][branch-1] TestExportSnapshotWithTemporaryDirectory (#2472)

This is an automated email from the ASF dual-hosted git repository.

reidchan pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1 by this push:
     new 6edeb5d  HBASE-25122 [Flake Test][branch-1] TestExportSnapshotWithTemporaryDirectory (#2472)
6edeb5d is described below

commit 6edeb5d1ecfd8b0155ff3c9022c6de2101565177
Author: Reid Chan <re...@apache.org>
AuthorDate: Wed Sep 30 18:55:28 2020 +0800

    HBASE-25122 [Flake Test][branch-1] TestExportSnapshotWithTemporaryDirectory (#2472)
    
    * Remove unused imports
    
    Signed-off-by: Viraj Jasani <vj...@apache.org>
---
 .../hadoop/hbase/snapshot/TestExportSnapshot.java   |  6 ++----
 .../TestExportSnapshotWithTemporaryDirectory.java   | 21 +++++++--------------
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
index f045ada..e96a1de 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
@@ -40,8 +40,6 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
 import org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotFileInfo;
@@ -67,7 +65,7 @@ import org.junit.rules.TestRule;
 public class TestExportSnapshot {
   @Rule public final TestRule timeout = CategoryBasedTimeout.builder().
       withTimeout(this.getClass()).withLookingForStuckThread(true).build();
-  private static final Log LOG = LogFactory.getLog(TestExportSnapshot.class);
+  protected static final Log LOG = LogFactory.getLog(TestExportSnapshot.class);
 
   protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
 
@@ -79,7 +77,7 @@ public class TestExportSnapshot {
   private TableName tableName;
   private Admin admin;
 
-  public static void setUpBaseConf(Configuration conf) {
+  public static void setUpBaseConf(Configuration conf) throws Exception  {
     conf.setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
     conf.setInt("hbase.regionserver.msginterval", 100);
     conf.setInt("hbase.client.pause", 250);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotWithTemporaryDirectory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotWithTemporaryDirectory.java
index d50f262..b9c69d7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotWithTemporaryDirectory.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshotWithTemporaryDirectory.java
@@ -17,10 +17,6 @@
  */
 package org.apache.hadoop.hbase.snapshot;
 
-import java.io.File;
-import java.nio.file.Paths;
-import java.util.UUID;
-import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
@@ -31,24 +27,21 @@ import org.junit.experimental.categories.Category;
 @Category({MediumTests.class})
 public class TestExportSnapshotWithTemporaryDirectory extends TestExportSnapshot {
 
-  protected static String TEMP_DIR = Paths.get("").toAbsolutePath().toString() + Path.SEPARATOR
-      + UUID.randomUUID().toString();
-
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
-    setUpBaseConf(TEST_UTIL.getConfiguration());
+    Configuration conf = TEST_UTIL.getConfiguration();
+    TestExportSnapshot.setUpBaseConf(conf);
     TEST_UTIL.startMiniCluster(3);
+    Path rootDir = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
+    LOG.info("Root dir: " + rootDir);
+    conf.set(SnapshotDescriptionUtils.SNAPSHOT_WORKING_DIR,
+      new Path(rootDir.getParent(), ".tmpdir").toUri().toString());
     TEST_UTIL.startMiniMapReduceCluster();
   }
 
   @AfterClass
   public static void tearDownAfterClass() throws Exception {
     TestExportSnapshot.tearDownAfterClass();
-    FileUtils.deleteDirectory(new File(TEMP_DIR));
   }
 
-  public static void setUpBaseConf(Configuration conf) {
-    TestExportSnapshot.setUpBaseConf(conf);
-    conf.set(SnapshotDescriptionUtils.SNAPSHOT_WORKING_DIR,  "file://" + new Path(TEMP_DIR, ".tmpdir").toUri());
-  }
-}
\ No newline at end of file
+}