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