From 4eb577c9f04767e72852641690c55f42b52a2b12 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Fri, 16 Jun 2017 00:22:24 +0900 Subject: [PATCH] Revert "HDFS-11736. OIV tests should not write outside 'target' directory. Contributed by Yiqun Lin." This reverts commit a52315d2c3f758fff2be75e42928576752616bcd. --- .../hadoop/hdfs/server/namenode/TestCheckpoint.java | 4 ++-- .../hdfs/server/namenode/ha/TestStandbyCheckpoints.java | 8 ++------ .../tools/offlineImageViewer/TestOfflineImageViewer.java | 7 +++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java index 5737ba2dde2..d914b0912d7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java @@ -44,6 +44,7 @@ import java.util.Collection; import java.util.List; import java.util.Random; +import com.google.common.io.Files; import org.apache.commons.cli.ParseException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -2437,8 +2438,7 @@ public class TestCheckpoint { public void testLegacyOivImage() throws Exception { MiniDFSCluster cluster = null; SecondaryNameNode secondary = null; - File tmpDir = GenericTestUtils.getTestDir("testLegacyOivImage"); - tmpDir.mkdirs(); + File tmpDir = Files.createTempDir(); Configuration conf = new HdfsConfiguration(); conf.set(DFSConfigKeys.DFS_NAMENODE_LEGACY_OIV_IMAGE_DIR_KEY, tmpDir.getAbsolutePath()); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java index f245755037c..0a4e4d107fa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java @@ -21,6 +21,7 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import com.google.common.io.Files; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -113,8 +114,7 @@ public class TestStandbyCheckpoints { } protected Configuration setupCommonConfig() { - tmpOivImgDir = GenericTestUtils.getTestDir("TestStandbyCheckpoints"); - tmpOivImgDir.mkdirs(); + tmpOivImgDir = Files.createTempDir(); Configuration conf = new Configuration(); conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_CHECK_PERIOD_KEY, 1); @@ -136,10 +136,6 @@ public class TestStandbyCheckpoints { cluster.shutdown(); cluster = null; } - - if (tmpOivImgDir != null) { - FileUtil.fullyDelete(tmpOivImgDir); - } } @Test(timeout = 300000) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java index 3c2724cbd2a..6ec237493c6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java @@ -56,6 +56,8 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import com.google.common.io.Files; + import org.apache.commons.io.FileUtils; import org.apache.commons.io.output.NullOutputStream; import org.apache.commons.logging.Log; @@ -114,10 +116,7 @@ public class TestOfflineImageViewer { // multiple tests. @BeforeClass public static void createOriginalFSImage() throws IOException { - File[] nnDirs = MiniDFSCluster.getNameNodeDirectory( - MiniDFSCluster.getBaseDirectory(), 0, 0); - tempDir = nnDirs[0]; - + tempDir = Files.createTempDir(); MiniDFSCluster cluster = null; try { Configuration conf = new Configuration();