HDFS-3128. Unit tests should not use a test root in /tmp. (wang)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1568527 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7e252cdc9d
commit
be69bfc2f4
|
@ -90,10 +90,6 @@ public abstract class FSMainOperationsBaseTest extends FileSystemTestHelper {
|
|||
public FSMainOperationsBaseTest() {
|
||||
}
|
||||
|
||||
public FSMainOperationsBaseTest(String testRootDir) {
|
||||
super(testRootDir);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
fSys = createFileSystem();
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class FileContextTestHelper {
|
|||
/**
|
||||
* Create a context with the given test root
|
||||
*/
|
||||
public FileContextTestHelper(String testRootDir) {
|
||||
private FileContextTestHelper(String testRootDir) {
|
||||
this.testRootDir = testRootDir;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FileSystemTestHelper {
|
|||
/**
|
||||
* Create helper with the specified test root dir
|
||||
*/
|
||||
public FileSystemTestHelper(String testRootDir) {
|
||||
private FileSystemTestHelper(String testRootDir) {
|
||||
this.testRootDir = testRootDir;
|
||||
}
|
||||
|
||||
|
|
|
@ -144,6 +144,8 @@ Release 2.4.0 - UNRELEASED
|
|||
HDFS-5943. 'dfs.namenode.https-address' property is not loaded from
|
||||
configuration in federation setup. (suresh)
|
||||
|
||||
HDFS-3128. Unit tests should not use a test root in /tmp. (wang)
|
||||
|
||||
Release 2.3.1 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TestFcHdfsCreateMkdir extends
|
|||
|
||||
@Override
|
||||
protected FileContextTestHelper createFileContextHelper() {
|
||||
return new FileContextTestHelper("/tmp/TestFcHdfsCreateMkdir");
|
||||
return new FileContextTestHelper();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.junit.BeforeClass;
|
|||
public class TestFcHdfsPermission extends FileContextPermissionBase {
|
||||
|
||||
private static final FileContextTestHelper fileContextTestHelper =
|
||||
new FileContextTestHelper("/tmp/TestFcHdfsPermission");
|
||||
new FileContextTestHelper();
|
||||
private static FileContext fc;
|
||||
|
||||
private static MiniDFSCluster cluster;
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.junit.Test;
|
|||
public class TestFcHdfsSetUMask {
|
||||
|
||||
private static FileContextTestHelper fileContextTestHelper =
|
||||
new FileContextTestHelper("/tmp/TestFcHdfsSetUMask");
|
||||
new FileContextTestHelper();
|
||||
private static MiniDFSCluster cluster;
|
||||
private static Path defaultWorkingDirectory;
|
||||
private static FileContext fc;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TestHDFSFileContextMainOperations extends
|
|||
|
||||
@Override
|
||||
protected FileContextTestHelper createFileContextHelper() {
|
||||
return new FileContextTestHelper("/tmp/TestHDFSFileContextMainOperations");
|
||||
return new FileContextTestHelper();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.junit.Test;
|
|||
* underlying file system as Hdfs.
|
||||
*/
|
||||
public class TestResolveHdfsSymlink {
|
||||
private static File TEST_ROOT_DIR = PathUtils.getTestDir(TestResolveHdfsSymlink.class);
|
||||
private static FileContextTestHelper helper = new FileContextTestHelper();
|
||||
private static MiniDFSCluster cluster = null;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -82,13 +82,14 @@ public class TestResolveHdfsSymlink {
|
|||
FileContext fcHdfs = FileContext.getFileContext(cluster.getFileSystem()
|
||||
.getUri());
|
||||
|
||||
final String localTestRoot = helper.getAbsoluteTestRootDir(fcLocal);
|
||||
Path alphaLocalPath = new Path(fcLocal.getDefaultFileSystem().getUri()
|
||||
.toString(), new File(TEST_ROOT_DIR, "alpha").getAbsolutePath());
|
||||
.toString(), new File(localTestRoot, "alpha").getAbsolutePath());
|
||||
DFSTestUtil.createFile(FileSystem.getLocal(conf), alphaLocalPath, 16,
|
||||
(short) 1, 2);
|
||||
|
||||
Path linkTarget = new Path(fcLocal.getDefaultFileSystem().getUri()
|
||||
.toString(), TEST_ROOT_DIR.getAbsolutePath());
|
||||
.toString(), localTestRoot);
|
||||
Path hdfsLink = new Path(fcHdfs.getDefaultFileSystem().getUri().toString(),
|
||||
"/tmp/link");
|
||||
fcHdfs.createSymlink(linkTarget, hdfsLink, true);
|
||||
|
|
|
@ -42,8 +42,7 @@ public class TestSymlinkHdfsDisable {
|
|||
DistributedFileSystem dfs = cluster.getFileSystem();
|
||||
FileContext fc = FileContext.getFileContext(cluster.getURI(0), conf);
|
||||
// Create test files/links
|
||||
FileContextTestHelper helper = new FileContextTestHelper(
|
||||
"/tmp/TestSymlinkHdfsDisable");
|
||||
FileContextTestHelper helper = new FileContextTestHelper();
|
||||
Path root = helper.getTestRootPath(fc);
|
||||
Path target = new Path(root, "target");
|
||||
Path link = new Path(root, "link");
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TestViewFileSystemAtHdfsRoot extends ViewFileSystemBaseTest {
|
|||
|
||||
@Override
|
||||
protected FileSystemTestHelper createFileSystemHelper() {
|
||||
return new FileSystemTestHelper("/tmp/TestViewFileSystemAtHdfsRoot");
|
||||
return new FileSystemTestHelper();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TestViewFileSystemHdfs extends ViewFileSystemBaseTest {
|
|||
|
||||
@Override
|
||||
protected FileSystemTestHelper createFileSystemHelper() {
|
||||
return new FileSystemTestHelper("/tmp/TestViewFileSystemHdfs");
|
||||
return new FileSystemTestHelper();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -46,7 +46,7 @@ public class TestViewFsAtHdfsRoot extends ViewFsBaseTest {
|
|||
|
||||
@Override
|
||||
protected FileContextTestHelper createFileContextHelper() {
|
||||
return new FileContextTestHelper("/tmp/TestViewFsAtHdfsRoot");
|
||||
return new FileContextTestHelper();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TestViewFsHdfs extends ViewFsBaseTest {
|
|||
|
||||
@Override
|
||||
protected FileContextTestHelper createFileContextHelper() {
|
||||
return new FileContextTestHelper("/tmp/TestViewFsHdfs");
|
||||
return new FileContextTestHelper();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TestFSMainOperationsWebHdfs extends FSMainOperationsBaseTest {
|
|||
private static FileSystem fileSystem;
|
||||
|
||||
public TestFSMainOperationsWebHdfs() {
|
||||
super("/tmp/TestFSMainOperationsWebHdfs");
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.test;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
|
||||
public class PathUtils {
|
||||
|
@ -36,7 +37,10 @@ public class PathUtils {
|
|||
}
|
||||
|
||||
public static File getTestDir(Class<?> caller, boolean create) {
|
||||
File dir = new File(System.getProperty("test.build.data", "/tmp"), caller.getSimpleName());
|
||||
File dir =
|
||||
new File(System.getProperty("test.build.data", "target/test/data")
|
||||
+ "/" + RandomStringUtils.randomAlphanumeric(10),
|
||||
caller.getSimpleName());
|
||||
if (create) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue