From c5821cf38bdfdb281e62c8386cccce7c095abc3f Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Wed, 12 Jun 2013 17:21:47 +0000 Subject: [PATCH] HADOOP-9638. Parallel test changes caused invalid test path for several HDFS tests on Windows. Contributed by Andrey Klochkov. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1492297 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../hadoop/fs/FileContextMainOperationsBaseTest.java | 8 +++++++- .../org/apache/hadoop/fs/FileContextTestHelper.java | 10 +++++++++- .../org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java | 6 +++++- .../org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java | 6 ++++++ .../org/apache/hadoop/fs/TestFcHdfsPermission.java | 4 ++-- .../java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java | 3 ++- .../java/org/apache/hadoop/fs/TestFcHdfsSymlink.java | 3 ++- .../hadoop/fs/TestHDFSFileContextMainOperations.java | 6 +++++- .../apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java | 6 ++++++ .../org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java | 7 +++++++ .../hadoop/hdfs/web/TestFSMainOperationsWebHdfs.java | 4 ++++ 12 files changed, 58 insertions(+), 8 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index c678938cb4..b0eb86f24b 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -582,6 +582,9 @@ Release 2.1.0-beta - UNRELEASED HADOOP-9581. hadoop --config non-existent directory should result in error (Ashwin Shankar via jlowe) + HADOOP-9638. Parallel test changes caused invalid test path for several HDFS + tests on Windows (Andrey Klochkov via cnauroth) + BREAKDOWN OF HADOOP-8562 SUBTASKS AND RELATED JIRAS HADOOP-8924. Hadoop Common creating package-info.java must not depend on diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java index 8f74b46050..2cf611fc70 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java @@ -65,7 +65,13 @@ public abstract class FileContextMainOperationsBaseTest { public Path localFsRootPath; - protected final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper(); + protected final FileContextTestHelper fileContextTestHelper = + createFileContextHelper(); + + protected FileContextTestHelper createFileContextHelper() { + return new FileContextTestHelper(); + } + protected static FileContext fc; final private static PathFilter DEFAULT_FILTER = new PathFilter() { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java index d40528b308..f3753c3d9d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java @@ -42,7 +42,15 @@ public final class FileContextTestHelper { * Create a context with test root relative to the /build/test/data */ public FileContextTestHelper() { - testRootDir = System.getProperty("test.build.data", "target/test/data") + "/" + RandomStringUtils.randomAlphanumeric(10); + this(System.getProperty("test.build.data", "target/test/data") + "/" + + RandomStringUtils.randomAlphanumeric(10)); + } + + /** + * Create a context with the given test root + */ + public FileContextTestHelper(String testRootDir) { + this.testRootDir = testRootDir; } public static int getDefaultBlockSize() { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java index 71894e6da9..0f771cd3ba 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java @@ -75,7 +75,11 @@ public class ViewFsBaseTest { Configuration conf; FileContext xfcViewWithAuthority; // same as fsView but with authority URI schemeWithAuthority; - final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper(); + final FileContextTestHelper fileContextTestHelper = createFileContextHelper(); + + protected FileContextTestHelper createFileContextHelper() { + return new FileContextTestHelper(); + } @Before public void setUp() throws Exception { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java index fe3054da77..40dbc4e88c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsCreateMkdir.java @@ -38,6 +38,12 @@ public class TestFcHdfsCreateMkdir extends private static MiniDFSCluster cluster; private static Path defaultWorkingDirectory; + @Override + protected FileContextTestHelper createFileContextHelper() { + return new FileContextTestHelper("/tmp/TestFcHdfsCreateMkdir"); + } + + @BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java index dc80205a6a..9f0b23cedf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsPermission.java @@ -24,7 +24,6 @@ import javax.security.auth.login.LoginException; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.security.UserGroupInformation; @@ -35,7 +34,8 @@ public class TestFcHdfsPermission extends FileContextPermissionBase { - private static final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper(); + private static final FileContextTestHelper fileContextTestHelper = + new FileContextTestHelper("/tmp/TestFcHdfsPermission"); private static FileContext fc; private static MiniDFSCluster cluster; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java index 52f032dd93..b6833dabba 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSetUMask.java @@ -42,7 +42,8 @@ public class TestFcHdfsSetUMask { - private static FileContextTestHelper fileContextTestHelper = new FileContextTestHelper(); + private static FileContextTestHelper fileContextTestHelper = + new FileContextTestHelper("/tmp/TestFcHdfsSetUMask"); private static MiniDFSCluster cluster; private static Path defaultWorkingDirectory; private static FileContext fc; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java index 2828cd0998..c59c75db56 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestFcHdfsSymlink.java @@ -50,7 +50,8 @@ public class TestFcHdfsSymlink extends FileContextSymlinkBaseTest { ((Log4JLogger)NameNode.stateChangeLog).getLogger().setLevel(Level.ALL); } - private static FileContextTestHelper fileContextTestHelper = new FileContextTestHelper(); + private static FileContextTestHelper fileContextTestHelper = + new FileContextTestHelper("/tmp/TestFcHdfsSymlink"); private static MiniDFSCluster cluster; private static WebHdfsFileSystem webhdfs; private static DistributedFileSystem dfs; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java index d1193f85ef..6388bdd9e7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java @@ -41,11 +41,15 @@ public class TestHDFSFileContextMainOperations extends FileContextMainOperationsBaseTest { - private static FileContextTestHelper fileContextTestHelper = new FileContextTestHelper(); private static MiniDFSCluster cluster; private static Path defaultWorkingDirectory; private static HdfsConfiguration CONF = new HdfsConfiguration(); + @Override + protected FileContextTestHelper createFileContextHelper() { + return new FileContextTestHelper("/tmp/TestHDFSFileContextMainOperations"); + } + @BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java index 0e35a4af7c..27020d8f7b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsAtHdfsRoot.java @@ -23,6 +23,7 @@ import javax.security.auth.login.LoginException; import org.apache.hadoop.fs.FileContext; +import org.apache.hadoop.fs.FileContextTestHelper; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.RemoteIterator; @@ -43,6 +44,11 @@ public class TestViewFsAtHdfsRoot extends ViewFsBaseTest { private static HdfsConfiguration CONF = new HdfsConfiguration(); private static FileContext fc; + @Override + protected FileContextTestHelper createFileContextHelper() { + return new FileContextTestHelper("/tmp/TestViewFsAtHdfsRoot"); + } + @BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java index 6d88eeb2de..8761762c9b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsHdfs.java @@ -24,6 +24,7 @@ import javax.security.auth.login.LoginException; import org.apache.hadoop.fs.FileContext; +import org.apache.hadoop.fs.FileContextTestHelper; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.HdfsConfiguration; @@ -39,6 +40,12 @@ public class TestViewFsHdfs extends ViewFsBaseTest { private static HdfsConfiguration CONF = new HdfsConfiguration(); private static FileContext fc; + @Override + protected FileContextTestHelper createFileContextHelper() { + return new FileContextTestHelper("/tmp/TestViewFsHdfs"); + } + + @BeforeClass public static void clusterSetupAtBegining() throws IOException, LoginException, URISyntaxException { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestFSMainOperationsWebHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestFSMainOperationsWebHdfs.java index 6ba605452c..ad2352b3e0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestFSMainOperationsWebHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestFSMainOperationsWebHdfs.java @@ -51,6 +51,10 @@ public class TestFSMainOperationsWebHdfs extends FSMainOperationsBaseTest { private static Path defaultWorkingDirectory; private static FileSystem fileSystem; + public TestFSMainOperationsWebHdfs() { + super("/tmp/TestFSMainOperationsWebHdfs"); + } + @Override protected FileSystem createFileSystem() throws Exception { return fileSystem;