HADOOP-12984. Add GenericTestUtils.getTestDir method and use it for emporary directory in tests (Contributed by Steve Loughran and Vinayakumar B
This closes #89 Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/8d29e245 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8d29e245 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8d29e245 Branch: refs/heads/HDFS-1312 Commit: 8d29e2451f5ca60f864c7ece16722c0abdd1c657 Parents: 654cd1d Author: Vinayakumar B <vinayakum...@apache.org> Authored: Thu Apr 7 10:12:00 2016 +0530 Committer: Vinayakumar B <vinayakum...@apache.org> Committed: Thu Apr 7 10:15:24 2016 +0530 ---------------------------------------------------------------------- .../apache/hadoop/conf/TestConfiguration.java | 8 +- .../crypto/TestCryptoStreamsForLocalFS.java | 5 +- .../apache/hadoop/crypto/key/TestKeyShell.java | 5 +- .../org/apache/hadoop/fs/FSTestWrapper.java | 3 +- .../fs/FileContextMainOperationsBaseTest.java | 4 +- .../apache/hadoop/fs/FileContextTestHelper.java | 6 +- .../apache/hadoop/fs/FileContextURIBase.java | 6 +- .../apache/hadoop/fs/FileSystemTestHelper.java | 4 +- .../org/apache/hadoop/fs/TestAvroFSInput.java | 9 +-- .../hadoop/fs/TestChecksumFileSystem.java | 5 +- .../org/apache/hadoop/fs/TestDFVariations.java | 2 +- .../test/java/org/apache/hadoop/fs/TestDU.java | 4 +- .../hadoop/fs/TestFileContextResolveAfs.java | 8 +- .../java/org/apache/hadoop/fs/TestFileUtil.java | 9 +-- .../org/apache/hadoop/fs/TestFsShellCopy.java | 6 +- .../apache/hadoop/fs/TestFsShellReturnCode.java | 8 +- .../org/apache/hadoop/fs/TestFsShellTouch.java | 6 +- .../hadoop/fs/TestGetFileBlockLocations.java | 5 +- .../hadoop/fs/TestHarFileSystemBasics.java | 5 +- .../java/org/apache/hadoop/fs/TestHardLink.java | 5 +- .../org/apache/hadoop/fs/TestListFiles.java | 14 ++-- .../apache/hadoop/fs/TestLocalFileSystem.java | 7 +- .../fs/TestLocalFileSystemPermission.java | 18 ++--- .../java/org/apache/hadoop/fs/TestPath.java | 6 +- .../java/org/apache/hadoop/fs/TestTrash.java | 6 +- .../apache/hadoop/fs/TestTruncatedInputBug.java | 4 +- .../hadoop/fs/sftp/TestSFTPFileSystem.java | 3 +- .../apache/hadoop/fs/shell/TestPathData.java | 5 +- .../apache/hadoop/fs/shell/TestTextCommand.java | 4 +- .../hadoop/fs/viewfs/TestViewfsFileStatus.java | 7 +- .../apache/hadoop/ha/ClientBaseWithFixes.java | 4 +- .../http/TestAuthenticationSessionCookie.java | 5 +- .../apache/hadoop/http/TestHttpCookieFlag.java | 5 +- .../hadoop/http/TestHttpServerLifecycle.java | 5 +- .../apache/hadoop/http/TestSSLHttpServer.java | 5 +- .../org/apache/hadoop/io/TestArrayFile.java | 6 +- .../org/apache/hadoop/io/TestBloomMapFile.java | 6 +- .../java/org/apache/hadoop/io/TestMapFile.java | 6 +- .../org/apache/hadoop/io/TestSequenceFile.java | 48 +++++------ .../hadoop/io/TestSequenceFileAppend.java | 4 +- .../io/TestSequenceFileSerialization.java | 4 +- .../apache/hadoop/io/TestSequenceFileSync.java | 5 +- .../java/org/apache/hadoop/io/TestSetFile.java | 5 +- .../apache/hadoop/io/compress/TestCodec.java | 23 +++--- .../apache/hadoop/io/file/tfile/TestTFile.java | 4 +- .../io/file/tfile/TestTFileByteArrays.java | 4 +- .../io/file/tfile/TestTFileComparator2.java | 4 +- .../io/file/tfile/TestTFileComparators.java | 5 +- .../hadoop/io/file/tfile/TestTFileSeek.java | 4 +- .../file/tfile/TestTFileSeqFileComparison.java | 5 +- .../hadoop/io/file/tfile/TestTFileSplit.java | 4 +- .../hadoop/io/file/tfile/TestTFileStreams.java | 4 +- .../file/tfile/TestTFileUnsortedByteArrays.java | 5 +- .../apache/hadoop/io/file/tfile/TestVLong.java | 4 +- .../apache/hadoop/io/nativeio/TestNativeIO.java | 10 +-- .../TestSharedFileDescriptorFactory.java | 4 +- .../sink/RollingFileSystemSinkTestBase.java | 6 +- .../apache/hadoop/security/TestCredentials.java | 4 +- .../hadoop/security/TestLdapGroupsMapping.java | 7 +- .../hadoop/security/alias/TestCredShell.java | 4 +- .../alias/TestCredentialProviderFactory.java | 5 +- .../hadoop/security/ssl/KeyStoreTestUtil.java | 4 +- .../ssl/TestReloadingX509TrustManager.java | 6 +- .../hadoop/security/ssl/TestSSLFactory.java | 6 +- .../apache/hadoop/test/GenericTestUtils.java | 84 +++++++++++++++++++- .../java/org/apache/hadoop/util/JarFinder.java | 4 +- .../hadoop/util/TestApplicationClassLoader.java | 4 +- .../org/apache/hadoop/util/TestClasspath.java | 5 +- .../hadoop/util/TestGenericOptionsParser.java | 2 +- .../apache/hadoop/util/TestHostsFileReader.java | 4 +- .../org/apache/hadoop/util/TestJarFinder.java | 9 ++- .../java/org/apache/hadoop/util/TestRunJar.java | 8 +- .../java/org/apache/hadoop/util/TestShell.java | 4 +- .../apache/hadoop/util/TestSysInfoLinux.java | 5 +- .../org/apache/hadoop/util/TestWinUtils.java | 5 +- .../java/org/apache/hadoop/util/TestZKUtil.java | 5 +- 76 files changed, 314 insertions(+), 242 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java index 46b2e50..aa3b239 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java @@ -49,6 +49,8 @@ import org.apache.hadoop.conf.Configuration.IntegerRanges; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.net.NetUtils; +import org.apache.hadoop.test.GenericTestUtils; + import static org.apache.hadoop.util.PlatformName.IBM_JAVA; import org.codehaus.jackson.map.ObjectMapper; @@ -427,8 +429,7 @@ public class TestConfiguration extends TestCase { Configuration conf = new Configuration(); String[] dirs = new String[]{"a", "b", "c"}; for (int i = 0; i < dirs.length; i++) { - dirs[i] = new Path(System.getProperty("test.build.data"), dirs[i]) - .toString(); + dirs[i] = new Path(GenericTestUtils.getTempPath(dirs[i])).toString(); } conf.set("dirs", StringUtils.join(dirs, ",")); for (int i = 0; i < 1000; i++) { @@ -444,8 +445,7 @@ public class TestConfiguration extends TestCase { Configuration conf = new Configuration(); String[] dirs = new String[]{"a", "b", "c"}; for (int i = 0; i < dirs.length; i++) { - dirs[i] = new Path(System.getProperty("test.build.data"), dirs[i]) - .toString(); + dirs[i] = new Path(GenericTestUtils.getTempPath(dirs[i])).toString(); } conf.set("dirs", StringUtils.join(dirs, ",")); for (int i = 0; i < 1000; i++) { http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoStreamsForLocalFS.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoStreamsForLocalFS.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoStreamsForLocalFS.java index 0a65085..235e9c2 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoStreamsForLocalFS.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/TestCryptoStreamsForLocalFS.java @@ -30,6 +30,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.fs.LocalFileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -38,8 +39,8 @@ import org.junit.Ignore; import org.junit.Test; public class TestCryptoStreamsForLocalFS extends CryptoStreamsTestBase { - private static final String TEST_ROOT_DIR - = System.getProperty("test.build.data","build/test/data") + "/work-dir/localfs"; + private static final String TEST_ROOT_DIR = + GenericTestUtils.getTempPath("work-dir/testcryptostreamsforlocalfs"); private final File base = new File(TEST_ROOT_DIR); private final Path file = new Path(TEST_ROOT_DIR, "test-file"); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyShell.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyShell.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyShell.java index fe88718..9e4a9ad 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyShell.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyShell.java @@ -25,6 +25,7 @@ import java.util.UUID; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -47,8 +48,8 @@ public class TestKeyShell { public void setup() throws Exception { outContent.reset(); errContent.reset(); - final File tmpDir = new File(System.getProperty("test.build.data", "target"), - UUID.randomUUID().toString()); + final File tmpDir = GenericTestUtils.getTestDir(UUID.randomUUID() + .toString()); if (!tmpDir.mkdirs()) { throw new IOException("Unable to create " + tmpDir); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSTestWrapper.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSTestWrapper.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSTestWrapper.java index c9e7e3c..da07105 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSTestWrapper.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSTestWrapper.java @@ -21,6 +21,7 @@ import java.io.IOException; import org.apache.commons.lang.RandomStringUtils; import org.apache.hadoop.fs.Options.CreateOpts; +import org.apache.hadoop.test.GenericTestUtils; /** * Abstraction of filesystem functionality with additional helper methods @@ -43,7 +44,7 @@ public abstract class FSTestWrapper implements FSWrapper { public FSTestWrapper(String testRootDir) { // Use default test dir if not provided if (testRootDir == null || testRootDir.isEmpty()) { - testRootDir = System.getProperty("test.build.data", "build/test/data"); + testRootDir = GenericTestUtils.getTestDir().getAbsolutePath(); } // salt test dir with some random digits for safe parallel runs this.testRootDir = testRootDir + "/" http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java ---------------------------------------------------------------------- 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 0c736a6..5f201eb 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 @@ -29,6 +29,7 @@ import org.apache.hadoop.HadoopIllegalArgumentException; import org.apache.hadoop.fs.Options.CreateOpts; import org.apache.hadoop.fs.Options.Rename; import org.apache.hadoop.fs.permission.FsPermission; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.After; import org.junit.Assert; import static org.junit.Assert.*; @@ -99,8 +100,7 @@ public abstract class FileContextMainOperationsBaseTest { @Before public void setUp() throws Exception { - File testBuildData = new File(System.getProperty("test.build.data", - "build/test/data"), RandomStringUtils.randomAlphanumeric(10)); + File testBuildData = GenericTestUtils.getRandomizedTestDir(); Path rootPath = new Path(testBuildData.getAbsolutePath(), "root-uri"); localFsRootPath = rootPath.makeQualified(LocalFileSystem.NAME, null); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java ---------------------------------------------------------------------- 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 677aa03..5bf842c 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 @@ -26,6 +26,7 @@ import org.apache.commons.lang.RandomStringUtils; import org.apache.hadoop.fs.Options.CreateOpts; import org.apache.hadoop.fs.Options.CreateOpts.BlockSize; import org.apache.hadoop.io.IOUtils; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Assert; /** @@ -39,11 +40,10 @@ public final class FileContextTestHelper { private String absTestRootDir = null; /** - * Create a context with test root relative to the <wd>/build/test/data + * Create a context with test root relative to the test directory */ public FileContextTestHelper() { - this(System.getProperty("test.build.data", "target/test/data") + "/" + - RandomStringUtils.randomAlphanumeric(10)); + this(GenericTestUtils.getRandomizedTestDir().getAbsolutePath()); } /** http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextURIBase.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextURIBase.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextURIBase.java index 4082737..0a6ba65 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextURIBase.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextURIBase.java @@ -21,6 +21,8 @@ package org.apache.hadoop.fs; import java.io.*; import java.util.ArrayList; import java.util.regex.Pattern; + +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Assert; import org.apache.hadoop.fs.permission.FsPermission; @@ -51,8 +53,8 @@ import static org.apache.hadoop.fs.FileContextTestHelper.*; * </p> */ public abstract class FileContextURIBase { - private static final String basePath = System.getProperty("test.build.data", - "build/test/data") + "/testContextURI"; + private static final String basePath = + GenericTestUtils.getTempPath("testContextURI"); private static final Path BASE = new Path(basePath); // Matches anything containing <, >, :, ", |, ?, *, or anything that ends with http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java index 4a88c51..c9d1781 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java @@ -22,9 +22,9 @@ import java.io.FileNotFoundException; import java.net.URI; import java.util.Random; -import org.apache.commons.lang.RandomStringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.token.Token; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Assert; import static org.junit.Assert.*; @@ -45,7 +45,7 @@ public class FileSystemTestHelper { * Create helper with test root located at <wd>/build/test/data */ public FileSystemTestHelper() { - this(System.getProperty("test.build.data", "target/test/data") + "/" + RandomStringUtils.randomAlphanumeric(10)); + this(GenericTestUtils.getRandomizedTempPath()); } /** http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java index 3e5970d..4009a60 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java @@ -22,6 +22,7 @@ import java.io.BufferedWriter; import java.io.OutputStreamWriter; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; import junit.framework.TestCase; @@ -30,15 +31,9 @@ public class TestAvroFSInput extends TestCase { private static final String INPUT_DIR = "AvroFSInput"; private Path getInputPath() { - String dataDir = System.getProperty("test.build.data"); - if (null == dataDir) { - return new Path(INPUT_DIR); - } else { - return new Path(new Path(dataDir), INPUT_DIR); - } + return new Path(GenericTestUtils.getTempPath(INPUT_DIR)); } - public void testAFSInput() throws Exception { Configuration conf = new Configuration(); FileSystem fs = FileSystem.getLocal(conf); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java index 923d219..9b7175e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java @@ -22,12 +22,13 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FSDataOutputStream; import static org.apache.hadoop.fs.FileSystemTestHelper.*; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.*; import static org.junit.Assert.*; public class TestChecksumFileSystem { - static final String TEST_ROOT_DIR - = System.getProperty("test.build.data","build/test/data/work-dir/localfs"); + static final String TEST_ROOT_DIR = + GenericTestUtils.getTempPath("work-dir/localfs"); static LocalFileSystem localFs; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java index 97dbe5e..3476f3e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java @@ -37,7 +37,7 @@ import static org.junit.Assert.*; public class TestDFVariations { private static final String TEST_ROOT_DIR = - System.getProperty("test.build.data","build/test/data") + "/TestDFVariations"; + GenericTestUtils.getTestDir("testdfvariations").getAbsolutePath(); private static File test_root = null; @Before http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java index 3add2a7..dded9fb 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java @@ -26,11 +26,11 @@ import java.util.Random; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeys; +import org.apache.hadoop.test.GenericTestUtils; /** This test makes sure that "DU" does not get to run on each call to getUsed */ public class TestDU extends TestCase { - final static private File DU_DIR = new File( - System.getProperty("test.build.data","/tmp"), "dutmp"); + final static private File DU_DIR = GenericTestUtils.getTestDir("dutmp"); @Override public void setUp() { http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextResolveAfs.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextResolveAfs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextResolveAfs.java index 1fe82e9..96fac57 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextResolveAfs.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextResolveAfs.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Set; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -34,9 +35,10 @@ public class TestFileContextResolveAfs { static { FileSystem.enableSymlinks(); } - private static String TEST_ROOT_DIR_LOCAL - = System.getProperty("test.build.data","/tmp"); - + + private static String TEST_ROOT_DIR_LOCAL = + GenericTestUtils.getTestDir().getAbsolutePath(); + private FileContext fc; private FileSystem localFs; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java index a9ef5c0..2116a4b 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.fs; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.*; import java.io.File; @@ -55,9 +56,7 @@ import static org.mockito.Mockito.when; public class TestFileUtil { private static final Log LOG = LogFactory.getLog(TestFileUtil.class); - private static final String TEST_ROOT_DIR = System.getProperty( - "test.build.data", "/tmp") + "/fu"; - private static final File TEST_DIR = new File(TEST_ROOT_DIR); + private static final File TEST_DIR = GenericTestUtils.getTestDir("fu"); private static final String FILE = "x"; private static final String LINK = "y"; private static final String DIR = "dir"; @@ -962,10 +961,10 @@ public class TestFileUtil { @Test (timeout = 30000) public void testUntar() throws IOException { String tarGzFileName = System.getProperty("test.cache.data", - "build/test/cache") + "/test-untar.tgz"; + "target/test/cache") + "/test-untar.tgz"; String tarFileName = System.getProperty("test.cache.data", "build/test/cache") + "/test-untar.tar"; - String dataDir = System.getProperty("test.build.data", "build/test/data"); + File dataDir = GenericTestUtils.getTestDir(); File untarDir = new File(dataDir, "untarDir"); doUntarAndVerify(new File(tarGzFileName), untarDir); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java index c00ed66..9e199ca 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java @@ -32,6 +32,7 @@ import java.io.IOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.StringUtils; import org.junit.Before; import org.junit.BeforeClass; @@ -50,9 +51,8 @@ public class TestFsShellCopy { conf = new Configuration(); shell = new FsShell(conf); lfs = FileSystem.getLocal(conf); - testRootDir = lfs.makeQualified(new Path( - System.getProperty("test.build.data","test/build/data"), - "testFsShellCopy")); + testRootDir = lfs.makeQualified(new Path(GenericTestUtils.getTempPath( + "testFsShellCopy"))); lfs.mkdirs(testRootDir); lfs.setWorkingDirectory(testRootDir); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java index a2276ec..38ad65b 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java @@ -41,6 +41,8 @@ import org.apache.hadoop.fs.shell.FsCommand; import org.apache.hadoop.fs.shell.PathData; import org.apache.hadoop.io.IOUtils; import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY; + +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Shell; import org.junit.BeforeClass; import org.junit.Test; @@ -63,9 +65,9 @@ public class TestFsShellReturnCode { fileSys = FileSystem.get(conf); fsShell = new FsShell(conf); } - - private static String TEST_ROOT_DIR = System.getProperty("test.build.data", - "build/test/data/testCHReturnCode"); + + private static String TEST_ROOT_DIR = + GenericTestUtils.getTempPath("testCHReturnCode"); static void writeFile(FileSystem fs, Path name) throws Exception { FSDataOutputStream stm = fs.create(name); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellTouch.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellTouch.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellTouch.java index 988a57c..89c886e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellTouch.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellTouch.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertThat; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.StringUtils; import org.junit.Before; import org.junit.BeforeClass; @@ -41,9 +42,8 @@ public class TestFsShellTouch { Configuration conf = new Configuration(); shell = new FsShell(conf); lfs = FileSystem.getLocal(conf); - testRootDir = lfs.makeQualified(new Path( - System.getProperty("test.build.data","test/build/data"), - "testFsShell")); + testRootDir = lfs.makeQualified( + new Path(GenericTestUtils.getTempPath("testFsShell"))); lfs.mkdirs(testRootDir); lfs.setWorkingDirectory(testRootDir); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java index ccf98ac..87265f4 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java @@ -25,13 +25,14 @@ import java.util.Random; import junit.framework.TestCase; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; /** * Testing the correctness of FileSystem.getFileBlockLocations. */ public class TestGetFileBlockLocations extends TestCase { - private static String TEST_ROOT_DIR = - System.getProperty("test.build.data", "/tmp/testGetFileBlockLocations"); + private static String TEST_ROOT_DIR = GenericTestUtils.getTempPath( + "testGetFileBlockLocations"); private static final int FileLength = 4 * 1024 * 1024; // 4MB private Configuration conf; private Path path; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java index 53507b9..c58e731 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java @@ -20,6 +20,7 @@ package org.apache.hadoop.fs; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.permission.FsPermission; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Shell; import org.junit.After; import org.junit.Assert; @@ -45,8 +46,8 @@ import static org.junit.Assert.*; */ public class TestHarFileSystemBasics { - private static final String ROOT_PATH = System.getProperty("test.build.data", - "build/test/data"); + private static final String ROOT_PATH = + GenericTestUtils.getTempPath("testharfilesystembasics"); private static final Path rootPath; static { String root = new Path(new File(ROOT_PATH).getAbsolutePath(), "localfs") http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java index c68861c..b32b95e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java @@ -24,6 +24,7 @@ import java.io.FileWriter; import java.io.IOException; import java.util.Arrays; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.After; import static org.junit.Assert.*; import org.junit.Before; @@ -57,9 +58,7 @@ import static org.apache.hadoop.fs.HardLink.*; */ public class TestHardLink { - public static final String TEST_ROOT_DIR = - System.getProperty("test.build.data", "build/test/data") + "/test"; - final static private File TEST_DIR = new File(TEST_ROOT_DIR, "hl"); + final static private File TEST_DIR = GenericTestUtils.getTestDir("test/hl"); private static String DIR = "dir_"; //define source and target directories private static File src = new File(TEST_DIR, DIR + "src"); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestListFiles.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestListFiles.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestListFiles.java index df519c8..010754f 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestListFiles.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestListFiles.java @@ -22,11 +22,8 @@ import java.util.HashSet; import java.util.Random; import java.util.Set; -import org.apache.commons.logging.impl.Log4JLogger; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FSDataOutputStream; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.log4j.Level; import static org.junit.Assert.*; @@ -37,8 +34,8 @@ import org.junit.BeforeClass; * This class tests the FileStatus API. */ public class TestListFiles { - { - ((Log4JLogger)FileSystem.LOG).getLogger().setLevel(Level.ALL); + static { + GenericTestUtils.setLogLevel(FileSystem.LOG, Level.ALL); } static final long seed = 0xDEADBEEFL; @@ -53,9 +50,8 @@ public class TestListFiles { private static Path FILE3; static { - setTestPaths(new Path( - System.getProperty("test.build.data", "build/test/data/work-dir/localfs"), - "main_")); + setTestPaths(new Path(GenericTestUtils.getTempPath("testlistfiles"), + "main_")); } protected static Path getTestDir() { http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java index 912c4f4..3aadd2f 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java @@ -20,6 +20,7 @@ package org.apache.hadoop.fs; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem.Statistics; import org.apache.hadoop.io.IOUtils; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Shell; import org.apache.hadoop.util.StringUtils; @@ -45,10 +46,10 @@ import org.mockito.internal.util.reflection.Whitebox; * This class tests the local file system via the FileSystem abstraction. */ public class TestLocalFileSystem { - private static final String TEST_ROOT_DIR - = System.getProperty("test.build.data","build/test/data") + "/work-dir/localfs"; + private static final File base = + GenericTestUtils.getTestDir("work-dir/localfs"); - private final File base = new File(TEST_ROOT_DIR); + private static final String TEST_ROOT_DIR = base.getAbsolutePath(); private final Path TEST_PATH = new Path(TEST_ROOT_DIR, "test-file"); private Configuration conf; private LocalFileSystem fileSys; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java index 148cf3e..e37de19 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java @@ -19,7 +19,9 @@ package org.apache.hadoop.fs; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.permission.*; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.StringUtils; +import org.apache.log4j.Level; import org.apache.hadoop.util.Shell; import java.io.*; @@ -31,19 +33,11 @@ import junit.framework.*; * This class tests the local file system via the FileSystem abstraction. */ public class TestLocalFileSystemPermission extends TestCase { - static final String TEST_PATH_PREFIX = new Path(System.getProperty( - "test.build.data", "/tmp")).toString().replace(' ', '_') - + "/" + TestLocalFileSystemPermission.class.getSimpleName() + "_"; + static final String TEST_PATH_PREFIX = GenericTestUtils.getTempPath( + TestLocalFileSystemPermission.class.getSimpleName()); - { - try { - ((org.apache.commons.logging.impl.Log4JLogger)FileSystem.LOG).getLogger() - .setLevel(org.apache.log4j.Level.DEBUG); - } - catch(Exception e) { - System.out.println("Cannot change log level\n" - + StringUtils.stringifyException(e)); - } + static { + GenericTestUtils.setLogLevel(FileSystem.LOG, Level.DEBUG); } private Path writeFile(FileSystem fs, String name) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestPath.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestPath.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestPath.java index 94908da..e5b22f9 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestPath.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestPath.java @@ -26,6 +26,7 @@ import java.util.Arrays; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.AvroTestUtil; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Shell; import com.google.common.base.Joiner; @@ -402,9 +403,8 @@ public class TestPath extends TestCase { // This test is not meaningful on Windows where * is disallowed in file name. if (Shell.WINDOWS) return; FileSystem lfs = FileSystem.getLocal(new Configuration()); - Path testRoot = lfs.makeQualified(new Path( - System.getProperty("test.build.data","test/build/data"), - "testPathGlob")); + Path testRoot = lfs.makeQualified( + new Path(GenericTestUtils.getTempPath("testPathGlob"))); lfs.delete(testRoot, true); lfs.mkdirs(testRoot); assertTrue(lfs.isDirectory(testRoot)); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java index 88194fd..338aff6 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java @@ -34,6 +34,7 @@ import java.util.Set; import junit.framework.TestCase; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Time; /** @@ -41,9 +42,8 @@ import org.apache.hadoop.util.Time; */ public class TestTrash extends TestCase { - private final static Path TEST_DIR = - new Path(new File(System.getProperty("test.build.data","/tmp") - ).toURI().toString().replace(' ', '+'), "testTrash"); + private final static Path TEST_DIR = new Path(GenericTestUtils.getTempPath( + "testTrash")); protected static Path mkdir(FileSystem fs, Path p) throws IOException { assertTrue(fs.mkdirs(p)); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTruncatedInputBug.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTruncatedInputBug.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTruncatedInputBug.java index e7dabf9..41c4d47 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTruncatedInputBug.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTruncatedInputBug.java @@ -23,6 +23,7 @@ import java.io.IOException; import junit.framework.TestCase; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.test.GenericTestUtils; /** * test for the input truncation bug when mark/reset is used. @@ -30,8 +31,7 @@ import org.apache.hadoop.conf.Configuration; */ public class TestTruncatedInputBug extends TestCase { private static String TEST_ROOT_DIR = - new Path(System.getProperty("test.build.data","/tmp")) - .toString().replace(' ', '+'); + GenericTestUtils.getTestDir().getAbsolutePath(); private void writeFile(FileSystem fileSys, Path name, int nBytesToWrite) http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java index 06d9bf0..36aacee 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java @@ -29,6 +29,7 @@ import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Shell; import org.apache.sshd.SshServer; @@ -54,7 +55,7 @@ public class TestSFTPFileSystem { private static final String TEST_SFTP_DIR = "testsftp"; private static final String TEST_ROOT_DIR = - System.getProperty("test.build.data", "build/test/data"); + GenericTestUtils.getTestDir().getAbsolutePath(); @Rule public TestName name = new TestName(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathData.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathData.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathData.java index ea9e984..e3e574a 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathData.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathData.java @@ -29,14 +29,15 @@ import java.util.Arrays; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Shell; import org.junit.After; import org.junit.Before; import org.junit.Test; public class TestPathData { - private static final String TEST_ROOT_DIR = - System.getProperty("test.build.data","build/test/data") + "/testPD"; + private static final String TEST_ROOT_DIR = + GenericTestUtils.getTestDir("testPD").getAbsolutePath(); protected Configuration conf; protected FileSystem fs; protected Path testDir; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java index 0e33d6a..7b84836 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java @@ -33,6 +33,7 @@ import java.nio.file.Paths; import org.apache.commons.io.IOUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Test; /** @@ -41,8 +42,7 @@ import org.junit.Test; */ public class TestTextCommand { private static final File TEST_ROOT_DIR = - Paths.get(System.getProperty("test.build.data", "build/test/data"), - "testText").toFile(); + GenericTestUtils.getTestDir("testText"); private static final String AVRO_FILENAME = new File(TEST_ROOT_DIR, "weather.avro").toURI().getPath(); private static final String TEXT_FILENAME = http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java index 9eec749..be1caec 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java @@ -30,7 +30,7 @@ import org.apache.hadoop.fs.FsConstants; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.io.DataOutputBuffer; - +import org.apache.hadoop.test.GenericTestUtils; import org.junit.AfterClass; import org.junit.Test; import org.mockito.Mockito; @@ -44,9 +44,8 @@ import static org.junit.Assert.*; */ public class TestViewfsFileStatus { - private static final File TEST_DIR = - new File(System.getProperty("test.build.data", "/tmp"), - TestViewfsFileStatus.class.getSimpleName()); + private static final File TEST_DIR = GenericTestUtils.getTestDir( + TestViewfsFileStatus.class.getSimpleName()); @Test public void testFileStatusSerialziation() http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java index b1ce1d1..7396694 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java @@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.apache.hadoop.net.ServerSocketUtil; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Time; import org.apache.zookeeper.TestableZooKeeper; import org.apache.zookeeper.WatchedEvent; @@ -62,8 +63,7 @@ public abstract class ClientBaseWithFixes extends ZKTestCase { protected static final Logger LOG = LoggerFactory.getLogger(ClientBaseWithFixes.class); public static int CONNECTION_TIMEOUT = 30000; - static final File BASETEST = - new File(System.getProperty("test.build.data", "build")); + static final File BASETEST = GenericTestUtils.getTestDir(); protected final String hostPort = initHostPort(); protected int maxCnxns = 0; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestAuthenticationSessionCookie.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestAuthenticationSessionCookie.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestAuthenticationSessionCookie.java index 058633a..c51f1e8 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestAuthenticationSessionCookie.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestAuthenticationSessionCookie.java @@ -19,6 +19,7 @@ import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.authentication.server.AuthenticationFilter; import org.apache.hadoop.security.ssl.KeyStoreTestUtil; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.After; import org.junit.Test; import org.mortbay.log.Log; @@ -35,8 +36,8 @@ import java.net.HttpCookie; import java.util.List; public class TestAuthenticationSessionCookie { - private static final String BASEDIR = System.getProperty("test.build.dir", - "target/test-dir") + "/" + TestHttpCookieFlag.class.getSimpleName(); + private static final String BASEDIR = + GenericTestUtils.getTempPath(TestHttpCookieFlag.class.getSimpleName()); private static boolean isCookiePersistent; private static final long TOKEN_VALIDITY_SEC = 1000; private static long expires; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpCookieFlag.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpCookieFlag.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpCookieFlag.java index f93f663..8a722df 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpCookieFlag.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpCookieFlag.java @@ -20,6 +20,7 @@ import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.authentication.server.AuthenticationFilter; import org.apache.hadoop.security.ssl.KeyStoreTestUtil; import org.apache.hadoop.security.ssl.SSLFactory; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -37,8 +38,8 @@ import java.net.HttpCookie; import java.util.List; public class TestHttpCookieFlag { - private static final String BASEDIR = System.getProperty("test.build.dir", - "target/test-dir") + "/" + TestHttpCookieFlag.class.getSimpleName(); + private static final String BASEDIR = + GenericTestUtils.getTempPath(TestHttpCookieFlag.class.getSimpleName()); private static String keystoresDir; private static String sslConfDir; private static SSLFactory clientSslFactory; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServerLifecycle.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServerLifecycle.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServerLifecycle.java index edae3c2..40f1b3d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServerLifecycle.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServerLifecycle.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.http; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.log4j.Logger; import org.junit.Test; @@ -76,8 +77,8 @@ public class TestHttpServerLifecycle extends HttpServerFunctionalTest { public void testStartedServerWithRequestLog() throws Throwable { HttpRequestLogAppender requestLogAppender = new HttpRequestLogAppender(); requestLogAppender.setName("httprequestlog"); - requestLogAppender.setFilename(System.getProperty("test.build.data", "/tmp/") - + "jetty-name-yyyy_mm_dd.log"); + requestLogAppender.setFilename( + GenericTestUtils.getTempPath("jetty-name-yyyy_mm_dd.log")); Logger.getLogger(HttpServer2.class.getName() + ".test").addAppender(requestLogAppender); HttpServer2 server = null; server = createTestServer(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java index c5ecfa1..49d73d6 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestSSLHttpServer.java @@ -40,6 +40,7 @@ import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.ssl.KeyStoreTestUtil; import org.apache.hadoop.security.ssl.SSLFactory; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -51,8 +52,8 @@ import org.junit.Test; */ public class TestSSLHttpServer extends HttpServerFunctionalTest { - private static final String BASEDIR = System.getProperty("test.build.dir", - "target/test-dir") + "/" + TestSSLHttpServer.class.getSimpleName(); + private static final String BASEDIR = + GenericTestUtils.getTempPath(TestSSLHttpServer.class.getSimpleName()); private static final Log LOG = LogFactory.getLog(TestSSLHttpServer.class); private static Configuration conf; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestArrayFile.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestArrayFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestArrayFile.java index 8c8da4a..505aca7 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestArrayFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestArrayFile.java @@ -24,6 +24,7 @@ import java.io.*; import org.apache.commons.logging.*; import org.apache.hadoop.fs.*; import org.apache.hadoop.io.SequenceFile.CompressionType; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Progressable; import org.apache.hadoop.conf.*; import org.junit.Test; @@ -38,9 +39,8 @@ import static org.junit.Assert.fail; public class TestArrayFile { private static final Log LOG = LogFactory.getLog(TestArrayFile.class); - private static final Path TEST_DIR = new Path( - System.getProperty("test.build.data", "/tmp"), - TestMapFile.class.getSimpleName()); + private static final Path TEST_DIR = new Path(GenericTestUtils.getTempPath( + TestMapFile.class.getSimpleName())); private static String TEST_FILE = new Path(TEST_DIR, "test.array").toString(); @Test http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBloomMapFile.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBloomMapFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBloomMapFile.java index 55a9188..740540d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBloomMapFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestBloomMapFile.java @@ -38,6 +38,7 @@ import org.apache.hadoop.io.compress.CompressionInputStream; import org.apache.hadoop.io.compress.CompressionOutputStream; import org.apache.hadoop.io.compress.Compressor; import org.apache.hadoop.io.compress.Decompressor; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Progressable; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -49,9 +50,8 @@ import org.junit.Test; public class TestBloomMapFile { private static Configuration conf = new Configuration(); - private static final Path TEST_ROOT = new Path( - System.getProperty("test.build.data", "/tmp"), - TestMapFile.class.getSimpleName()); + private static final Path TEST_ROOT = new Path(GenericTestUtils.getTempPath( + TestMapFile.class.getSimpleName())); private static final Path TEST_DIR = new Path(TEST_ROOT, "testfile"); private static final Path TEST_FILE = new Path(TEST_ROOT, "testfile"); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMapFile.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMapFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMapFile.java index 3f14de0..ff8df7c 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMapFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMapFile.java @@ -37,6 +37,7 @@ import org.apache.hadoop.io.compress.CompressionInputStream; import org.apache.hadoop.io.compress.CompressionOutputStream; import org.apache.hadoop.io.compress.Compressor; import org.apache.hadoop.io.compress.Decompressor; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Progressable; import org.junit.Assert; import org.junit.Before; @@ -48,9 +49,8 @@ import static org.mockito.Mockito.*; public class TestMapFile { - private static final Path TEST_DIR = new Path( - System.getProperty("test.build.data", "/tmp"), - TestMapFile.class.getSimpleName()); + private static final Path TEST_DIR = new Path(GenericTestUtils.getTempPath( + TestMapFile.class.getSimpleName())); private static Configuration conf = new Configuration(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java index 4cb4e13..b76cff6 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java @@ -29,6 +29,7 @@ import org.apache.hadoop.io.SequenceFile.Metadata; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.compress.DefaultCodec; import org.apache.hadoop.io.serializer.avro.AvroReflectSerialization; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.conf.*; import org.junit.Test; @@ -58,11 +59,11 @@ public class TestSequenceFile { int count = 1024 * 10; int megabytes = 1; int factor = 5; - Path file = new Path(System.getProperty("test.build.data",".")+"/test.seq"); - Path recordCompressedFile = - new Path(System.getProperty("test.build.data",".")+"/test.rc.seq"); - Path blockCompressedFile = - new Path(System.getProperty("test.build.data",".")+"/test.bc.seq"); + Path file = new Path(GenericTestUtils.getTempPath("test.seq")); + Path recordCompressedFile = new Path(GenericTestUtils.getTempPath( + "test.rc.seq")); + Path blockCompressedFile = new Path(GenericTestUtils.getTempPath( + "test.bc.seq")); int seed = new Random().nextInt(); LOG.info("Seed = " + seed); @@ -320,13 +321,13 @@ public class TestSequenceFile { LOG.info("Testing SequenceFile with metadata"); int count = 1024 * 10; CompressionCodec codec = new DefaultCodec(); - Path file = new Path(System.getProperty("test.build.data",".")+"/test.seq.metadata"); - Path sortedFile = - new Path(System.getProperty("test.build.data",".")+"/test.sorted.seq.metadata"); - Path recordCompressedFile = - new Path(System.getProperty("test.build.data",".")+"/test.rc.seq.metadata"); - Path blockCompressedFile = - new Path(System.getProperty("test.build.data",".")+"/test.bc.seq.metadata"); + Path file = new Path(GenericTestUtils.getTempPath("test.seq.metadata")); + Path sortedFile = new Path(GenericTestUtils.getTempPath( + "test.sorted.seq.metadata")); + Path recordCompressedFile = new Path(GenericTestUtils.getTempPath( + "test.rc.seq.metadata")); + Path blockCompressedFile = new Path(GenericTestUtils.getTempPath( + "test.bc.seq.metadata")); FileSystem fs = FileSystem.getLocal(conf); SequenceFile.Metadata theMetadata = new SequenceFile.Metadata(); @@ -426,14 +427,14 @@ public class TestSequenceFile { LocalFileSystem fs = FileSystem.getLocal(conf); // create a sequence file 1 - Path path1 = new Path(System.getProperty("test.build.data",".")+"/test1.seq"); + Path path1 = new Path(GenericTestUtils.getTempPath("test1.seq")); SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, path1, Text.class, NullWritable.class, CompressionType.BLOCK); writer.append(new Text("file1-1"), NullWritable.get()); writer.append(new Text("file1-2"), NullWritable.get()); writer.close(); - Path path2 = new Path(System.getProperty("test.build.data",".")+"/test2.seq"); + Path path2 = new Path(GenericTestUtils.getTempPath("test2.seq")); writer = SequenceFile.createWriter(fs, conf, path2, Text.class, NullWritable.class, CompressionType.BLOCK); writer.append(new Text("file2-1"), NullWritable.get()); @@ -482,7 +483,7 @@ public class TestSequenceFile { public void testCreateUsesFsArg() throws Exception { FileSystem fs = FileSystem.getLocal(conf); FileSystem spyFs = Mockito.spy(fs); - Path p = new Path(System.getProperty("test.build.data", ".")+"/testCreateUsesFSArg.seq"); + Path p = new Path(GenericTestUtils.getTempPath("testCreateUsesFSArg.seq")); SequenceFile.Writer writer = SequenceFile.createWriter( spyFs, conf, p, NullWritable.class, NullWritable.class); writer.close(); @@ -515,7 +516,7 @@ public class TestSequenceFile { LocalFileSystem fs = FileSystem.getLocal(conf); // create an empty file (which is not a valid sequence file) - Path path = new Path(System.getProperty("test.build.data",".")+"/broken.seq"); + Path path = new Path(GenericTestUtils.getTempPath("broken.seq")); fs.create(path).close(); // try to create SequenceFile.Reader @@ -547,8 +548,7 @@ public class TestSequenceFile { LocalFileSystem fs = FileSystem.getLocal(conf); // create an empty file (which is not a valid sequence file) - Path path = new Path(System.getProperty("test.build.data", ".") + - "/zerolength.seq"); + Path path = new Path(GenericTestUtils.getTempPath("zerolength.seq")); fs.create(path).close(); try { @@ -569,8 +569,8 @@ public class TestSequenceFile { public void testCreateWriterOnExistingFile() throws IOException { Configuration conf = new Configuration(); FileSystem fs = FileSystem.getLocal(conf); - Path name = new Path(new Path(System.getProperty("test.build.data","."), - "createWriterOnExistingFile") , "file"); + Path name = new Path(new Path(GenericTestUtils.getTempPath( + "createWriterOnExistingFile")), "file"); fs.create(name); SequenceFile.createWriter(fs, conf, name, RandomDatum.class, @@ -582,8 +582,8 @@ public class TestSequenceFile { @Test public void testRecursiveSeqFileCreate() throws IOException { FileSystem fs = FileSystem.getLocal(conf); - Path name = new Path(new Path(System.getProperty("test.build.data","."), - "recursiveCreateDir") , "file"); + Path name = new Path(new Path(GenericTestUtils.getTempPath( + "recursiveCreateDir")), "file"); boolean createParent = false; try { @@ -605,8 +605,8 @@ public class TestSequenceFile { @Test public void testSerializationAvailability() throws IOException { Configuration conf = new Configuration(); - Path path = new Path(System.getProperty("test.build.data", "."), - "serializationAvailability"); + Path path = new Path(GenericTestUtils.getTempPath( + "serializationAvailability")); // Check if any serializers aren't found. try { SequenceFile.createWriter( http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileAppend.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileAppend.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileAppend.java index be4ab92..9e49c9e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileAppend.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileAppend.java @@ -43,8 +43,8 @@ public class TestSequenceFileAppend { private static Configuration conf; private static FileSystem fs; - private static Path ROOT_PATH = new Path(System.getProperty( - "test.build.data", "build/test/data")); + private static Path ROOT_PATH = + new Path(GenericTestUtils.getTestDir().getAbsolutePath()); @BeforeClass public static void setUp() throws Exception { http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java index 3ca9187..b1c519a 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSerialization.java @@ -24,6 +24,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.SequenceFile.Reader; import org.apache.hadoop.io.SequenceFile.Writer; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -50,8 +51,7 @@ public class TestSequenceFileSerialization { @Test public void testJavaSerialization() throws Exception { - Path file = new Path(System.getProperty("test.build.data",".") + - "/testseqser.seq"); + Path file = new Path(GenericTestUtils.getTempPath("testseqser.seq")); fs.delete(file, true); Writer writer = SequenceFile.createWriter(fs, conf, file, Long.class, http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSync.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSync.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSync.java index fb09425..bceb8af 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSync.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFileSync.java @@ -27,6 +27,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Test; public class TestSequenceFileSync { @@ -52,8 +53,8 @@ public class TestSequenceFileSync { public void testLowSyncpoint() throws IOException { final Configuration conf = new Configuration(); final FileSystem fs = FileSystem.getLocal(conf); - final Path path = new Path(System.getProperty("test.build.data", "/tmp"), - "sequencefile.sync.test"); + final Path path = new Path(GenericTestUtils.getTempPath( + "sequencefile.sync.test")); final IntWritable input = new IntWritable(); final Text val = new Text(); SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, path, http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSetFile.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSetFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSetFile.java index ff92b37..1fcfab6 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSetFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSetFile.java @@ -20,7 +20,6 @@ package org.apache.hadoop.io; import java.io.*; import java.util.*; -import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.logging.*; @@ -28,6 +27,7 @@ import org.apache.commons.logging.*; import org.apache.hadoop.fs.*; import org.apache.hadoop.conf.*; import org.apache.hadoop.io.SequenceFile.CompressionType; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Test; import static org.junit.Assert.assertTrue; @@ -38,8 +38,7 @@ import static org.junit.Assert.fail; /** Support for flat files of binary key/value pairs. */ public class TestSetFile { private static final Log LOG = LogFactory.getLog(TestSetFile.class); - private static String FILE = - System.getProperty("test.build.data",".") + "/test.set"; + private static String FILE = GenericTestUtils.getTempPath("test.set"); private static Configuration conf = new Configuration(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java index 1e3809e..5443ca7 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java @@ -72,6 +72,7 @@ import org.apache.hadoop.io.compress.zlib.BuiltInZlibInflater; import org.apache.hadoop.io.compress.zlib.ZlibCompressor; import org.apache.hadoop.io.compress.zlib.ZlibCompressor.CompressionLevel; import org.apache.hadoop.io.compress.zlib.ZlibCompressor.CompressionStrategy; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.io.compress.zlib.ZlibFactory; import org.apache.hadoop.util.LineReader; import org.apache.hadoop.util.NativeCodeLoader; @@ -338,9 +339,9 @@ public class TestCodec { private static Path writeSplitTestFile(FileSystem fs, Random rand, CompressionCodec codec, long infLen) throws IOException { final int REC_SIZE = 1024; - final Path wd = new Path(new Path( - System.getProperty("test.build.data", "/tmp")).makeQualified(fs), - codec.getClass().getSimpleName()); + final Path wd = new Path(GenericTestUtils.getTempPath( + codec.getClass().getSimpleName())).makeQualified( + fs.getUri(), fs.getWorkingDirectory()); final Path file = new Path(wd, "test" + codec.getDefaultExtension()); final byte[] b = new byte[REC_SIZE]; final Base64 b64 = new Base64(0, null); @@ -596,9 +597,8 @@ public class TestCodec { FileSystem fs = FileSystem.get(conf); LOG.info("Creating MapFiles with " + records + " records using codec " + clazz.getSimpleName()); - Path path = new Path(new Path( - System.getProperty("test.build.data", "/tmp")), - clazz.getSimpleName() + "-" + type + "-" + records); + Path path = new Path(GenericTestUtils.getTempPath( + clazz.getSimpleName() + "-" + type + "-" + records)); LOG.info("Writing " + path); createMapFile(conf, fs, path, clazz.newInstance(), type, records); @@ -750,8 +750,7 @@ public class TestCodec { CodecPool.returnDecompressor(zlibDecompressor); // Now create a GZip text file. - String tmpDir = System.getProperty("test.build.data", "/tmp/"); - Path f = new Path(new Path(tmpDir), "testGzipCodecRead.txt.gz"); + Path f = new Path(GenericTestUtils.getTempPath("testGzipCodecRead.txt.gz")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter( new GZIPOutputStream(new FileOutputStream(f.toString())))); final String msg = "This is the message in the file!"; @@ -802,8 +801,7 @@ public class TestCodec { CodecPool.returnDecompressor(zlibDecompressor); // Now create a GZip text file. - String tmpDir = System.getProperty("test.build.data", "/tmp/"); - Path f = new Path(new Path(tmpDir), "testGzipLongOverflow.bin.gz"); + Path f = new Path(GenericTestUtils.getTempPath("testGzipLongOverflow.bin.gz")); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter( new GZIPOutputStream(new FileOutputStream(f.toString())))); @@ -862,9 +860,8 @@ public class TestCodec { codec instanceof GzipCodec); final String msg = "This is the message we are going to compress."; - final String tmpDir = System.getProperty("test.build.data", "/tmp/"); - final String fileName = new Path(new Path(tmpDir), - "testGzipCodecWrite.txt.gz").toString(); + final String fileName = new Path(GenericTestUtils.getTempPath( + "testGzipCodecWrite.txt.gz")).toString(); BufferedWriter w = null; Compressor gzipCompressor = CodecPool.getCompressor(codec); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFile.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFile.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFile.java index df3f48d..80aeef2 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFile.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFile.java @@ -30,6 +30,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.file.tfile.TFile.Reader; import org.apache.hadoop.io.file.tfile.TFile.Writer; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner; import org.junit.After; import org.junit.Before; @@ -43,8 +44,7 @@ import static org.junit.Assert.assertFalse; * */ public class TestTFile { - private static String ROOT = - System.getProperty("test.build.data", "/tmp/tfile-test"); + private static String ROOT = GenericTestUtils.getTempPath("tfile-test"); private FileSystem fs; private Configuration conf; private static final int minBlockSize = 512; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java index 8040cdf..7051f00 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java @@ -35,6 +35,7 @@ import org.apache.hadoop.io.file.tfile.TFile.Reader; import org.apache.hadoop.io.file.tfile.TFile.Writer; import org.apache.hadoop.io.file.tfile.TFile.Reader.Location; import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -46,8 +47,7 @@ import org.junit.Test; * */ public class TestTFileByteArrays { - private static String ROOT = - System.getProperty("test.build.data", "/tmp/tfile-test"); + private static String ROOT = GenericTestUtils.getTestDir().getAbsolutePath(); private final static int BLOCK_SIZE = 512; private final static int BUF_SIZE = 64; private final static int K = 1024; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparator2.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparator2.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparator2.java index 9e13c71..5a8b5b3 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparator2.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparator2.java @@ -27,13 +27,13 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.file.tfile.TFile.Writer; +import org.apache.hadoop.test.GenericTestUtils; import org.junit.Test; import static org.junit.Assert.*; public class TestTFileComparator2 { - private static final String ROOT = System.getProperty("test.build.data", - "/tmp/tfile-test"); + private static String ROOT = GenericTestUtils.getTestDir().getAbsolutePath(); private static final String name = "test-tfile-comparator2"; private final static int BLOCK_SIZE = 512; private static final String VALUE = "value"; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparators.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparators.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparators.java index 198000b..e460062 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparators.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileComparators.java @@ -30,6 +30,7 @@ import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.file.tfile.TFile.Writer; +import org.apache.hadoop.test.GenericTestUtils; /** * @@ -38,9 +39,7 @@ import org.apache.hadoop.io.file.tfile.TFile.Writer; * */ public class TestTFileComparators { - private static String ROOT = - System.getProperty("test.build.data", "/tmp/tfile-test"); - + private static String ROOT = GenericTestUtils.getTestDir().getAbsolutePath(); private final static int BLOCK_SIZE = 512; private FileSystem fs; private Configuration conf; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeek.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeek.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeek.java index b362c42..f1eaec2 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeek.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeek.java @@ -45,6 +45,7 @@ import org.apache.hadoop.io.file.tfile.RandomDistribution.DiscreteRNG; import org.apache.hadoop.io.file.tfile.TFile.Reader; import org.apache.hadoop.io.file.tfile.TFile.Writer; import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner; +import org.apache.hadoop.test.GenericTestUtils; /** * test the performance for seek. @@ -246,8 +247,7 @@ public class TestTFileSeek { int fsOutputBufferSizeLzo = 1; int fsOutputBufferSizeGz = 1; - String rootDir = - System.getProperty("test.build.data", "/tmp/tfile-test"); + String rootDir = GenericTestUtils.getTestDir().getAbsolutePath(); String file = "TestTFileSeek"; String compress = "gz"; int minKeyLen = 10; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java index 5dd6d02..4892420 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java @@ -45,6 +45,7 @@ import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.SequenceFile; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner.Entry; +import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Time; public class TestTFileSeqFileComparison { @@ -515,9 +516,7 @@ public class TestTFileSeqFileComparison { } private static class MyOptions { - String rootDir = - System - .getProperty("test.build.data", "/tmp/tfile-test"); + String rootDir = GenericTestUtils.getTestDir().getAbsolutePath();; String compress = "gz"; String format = "tfile"; int dictSize = 1000; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSplit.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSplit.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSplit.java index 08695d9..613ae4f 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSplit.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSplit.java @@ -32,10 +32,10 @@ import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.file.tfile.TFile.Reader; import org.apache.hadoop.io.file.tfile.TFile.Writer; import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner; +import org.apache.hadoop.test.GenericTestUtils; public class TestTFileSplit { - private static String ROOT = - System.getProperty("test.build.data", "/tmp/tfile-test"); + private static String ROOT = GenericTestUtils.getTestDir().getAbsolutePath(); private final static int BLOCK_SIZE = 64 * 1024; http://git-wip-us.apache.org/repos/asf/hadoop/blob/8d29e245/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java index 6524c37..a108408 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileStreams.java @@ -37,6 +37,7 @@ import org.apache.hadoop.io.WritableUtils; import org.apache.hadoop.io.file.tfile.TFile.Reader; import org.apache.hadoop.io.file.tfile.TFile.Writer; import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner; +import org.apache.hadoop.test.GenericTestUtils; /** * @@ -46,8 +47,7 @@ import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner; */ public class TestTFileStreams { - private static String ROOT = - System.getProperty("test.build.data", "/tmp/tfile-test"); + private static String ROOT = GenericTestUtils.getTestDir().getAbsolutePath(); private final static int BLOCK_SIZE = 512; private final static int K = 1024;