From eb7af141e4b63831bf36edff2c9c38c2fdbe76af Mon Sep 17 00:00:00 2001
From: Jason Darrell Lowe
* A collection of tests for the {@link FileSystem}.
@@ -55,7 +53,7 @@ import static org.apache.hadoop.fs.FileSystemTestHelper.*;
* @AfterClass public static void ClusterShutdownAtEnd()
*
* Tests the File Context Statistics for {@link LocalFileSystem}
@@ -39,12 +37,12 @@ public class TestLocalFsFCStatistics extends FCStatisticsBaseTest {
@Before
public void setUp() throws Exception {
fc = FileContext.getLocalFSFileContext();
- fc.mkdir(getTestRootPath(fc, "test"), FileContext.DEFAULT_PERM, true);
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "test"), FileContext.DEFAULT_PERM, true);
}
@After
public void tearDown() throws Exception {
- fc.delete(getTestRootPath(fc, "test"), true);
+ fc.delete(fileContextTestHelper.getTestRootPath(fc, "test"), true);
}
@Override
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java
index bc30c5a8f08..9bc399e88ce 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java
@@ -97,37 +97,37 @@ public class TestCopyPreserveFlag {
assertEquals(0, cmd.run(args));
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testPutWithP() throws Exception {
run(new Put(), "-p", FROM.toString(), TO.toString());
assertAttributesPreserved();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testPutWithoutP() throws Exception {
run(new Put(), FROM.toString(), TO.toString());
assertAttributesChanged();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testGetWithP() throws Exception {
run(new Get(), "-p", FROM.toString(), TO.toString());
assertAttributesPreserved();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testGetWithoutP() throws Exception {
run(new Get(), FROM.toString(), TO.toString());
assertAttributesChanged();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testCpWithP() throws Exception {
run(new Cp(), "-p", FROM.toString(), TO.toString());
assertAttributesPreserved();
}
- @Test(timeout = 1000)
+ @Test(timeout = 10000)
public void testCpWithoutP() throws Exception {
run(new Cp(), FROM.toString(), TO.toString());
assertAttributesChanged();
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
index f2aace9472d..8454025ba3d 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
@@ -40,13 +40,15 @@ public class TestChRootedFileSystem {
FileSystem fSys; // The ChRoootedFs
FileSystem fSysTarget; //
Path chrootedTo;
-
+ FileSystemTestHelper fileSystemTestHelper;
+
@Before
public void setUp() throws Exception {
// create the test root on local_fs
Configuration conf = new Configuration();
fSysTarget = FileSystem.getLocal(conf);
- chrootedTo = FileSystemTestHelper.getAbsoluteTestRootPath(fSysTarget);
+ fileSystemTestHelper = new FileSystemTestHelper();
+ chrootedTo = fileSystemTestHelper.getAbsoluteTestRootPath(fSysTarget);
// In case previous test was killed before cleanup
fSysTarget.delete(chrootedTo, true);
@@ -107,12 +109,12 @@ public class TestChRootedFileSystem {
// Create file
- FileSystemTestHelper.createFile(fSys, "/foo");
+ fileSystemTestHelper.createFile(fSys, "/foo");
Assert.assertTrue(fSys.isFile(new Path("/foo")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo, "foo")));
// Create file with recursive dir
- FileSystemTestHelper.createFile(fSys, "/newDir/foo");
+ fileSystemTestHelper.createFile(fSys, "/newDir/foo");
Assert.assertTrue(fSys.isFile(new Path("/newDir/foo")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/foo")));
@@ -122,7 +124,7 @@ public class TestChRootedFileSystem {
Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo, "newDir/foo")));
// Create file with a 2 component dirs recursively
- FileSystemTestHelper.createFile(fSys, "/newDir/newDir2/foo");
+ fileSystemTestHelper.createFile(fSys, "/newDir/newDir2/foo");
Assert.assertTrue(fSys.isFile(new Path("/newDir/newDir2/foo")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/newDir2/foo")));
@@ -135,11 +137,11 @@ public class TestChRootedFileSystem {
@Test
public void testMkdirDelete() throws IOException {
- fSys.mkdirs(FileSystemTestHelper.getTestRootPath(fSys, "/dirX"));
+ fSys.mkdirs(fileSystemTestHelper.getTestRootPath(fSys, "/dirX"));
Assert.assertTrue(fSys.isDirectory(new Path("/dirX")));
Assert.assertTrue(fSysTarget.isDirectory(new Path(chrootedTo,"dirX")));
- fSys.mkdirs(FileSystemTestHelper.getTestRootPath(fSys, "/dirX/dirY"));
+ fSys.mkdirs(fileSystemTestHelper.getTestRootPath(fSys, "/dirX/dirY"));
Assert.assertTrue(fSys.isDirectory(new Path("/dirX/dirY")));
Assert.assertTrue(fSysTarget.isDirectory(new Path(chrootedTo,"dirX/dirY")));
@@ -157,11 +159,11 @@ public class TestChRootedFileSystem {
@Test
public void testRename() throws IOException {
// Rename a file
- FileSystemTestHelper.createFile(fSys, "/newDir/foo");
+ fileSystemTestHelper.createFile(fSys, "/newDir/foo");
fSys.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
Assert.assertFalse(fSys.exists(new Path("/newDir/foo")));
Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo,"newDir/foo")));
- Assert.assertTrue(fSys.isFile(FileSystemTestHelper.getTestRootPath(fSys,"/newDir/fooBar")));
+ Assert.assertTrue(fSys.isFile(fileSystemTestHelper.getTestRootPath(fSys,"/newDir/fooBar")));
Assert.assertTrue(fSysTarget.isFile(new Path(chrootedTo,"newDir/fooBar")));
@@ -170,7 +172,7 @@ public class TestChRootedFileSystem {
fSys.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
Assert.assertFalse(fSys.exists(new Path("/newDir/dirFoo")));
Assert.assertFalse(fSysTarget.exists(new Path(chrootedTo,"newDir/dirFoo")));
- Assert.assertTrue(fSys.isDirectory(FileSystemTestHelper.getTestRootPath(fSys,"/newDir/dirFooBar")));
+ Assert.assertTrue(fSys.isDirectory(fileSystemTestHelper.getTestRootPath(fSys,"/newDir/dirFooBar")));
Assert.assertTrue(fSysTarget.isDirectory(new Path(chrootedTo,"newDir/dirFooBar")));
}
@@ -214,10 +216,10 @@ public class TestChRootedFileSystem {
- FileSystemTestHelper.createFile(fSys, "/foo");
- FileSystemTestHelper.createFile(fSys, "/bar");
+ fileSystemTestHelper.createFile(fSys, "/foo");
+ fileSystemTestHelper.createFile(fSys, "/bar");
fSys.mkdirs(new Path("/dirX"));
- fSys.mkdirs(FileSystemTestHelper.getTestRootPath(fSys, "/dirY"));
+ fSys.mkdirs(fileSystemTestHelper.getTestRootPath(fSys, "/dirY"));
fSys.mkdirs(new Path("/dirX/dirXX"));
dirPaths = fSys.listStatus(new Path("/"));
@@ -307,7 +309,7 @@ public class TestChRootedFileSystem {
@Test
public void testResolvePath() throws IOException {
Assert.assertEquals(chrootedTo, fSys.resolvePath(new Path("/")));
- FileSystemTestHelper.createFile(fSys, "/foo");
+ fileSystemTestHelper.createFile(fSys, "/foo");
Assert.assertEquals(new Path(chrootedTo, "foo"),
fSys.resolvePath(new Path("/foo")));
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
index c52280154d6..6078bc0caa2 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
@@ -38,6 +38,7 @@ import org.junit.Before;
import org.junit.Test;
public class TestChRootedFs {
+ FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
FileContext fc; // The ChRoootedFs
FileContext fcTarget; //
Path chrootedTo;
@@ -46,7 +47,7 @@ public class TestChRootedFs {
public void setUp() throws Exception {
// create the test root on local_fs
fcTarget = FileContext.getLocalFSFileContext();
- chrootedTo = FileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
+ chrootedTo = fileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
// In case previous test was killed before cleanup
fcTarget.delete(chrootedTo, true);
@@ -105,12 +106,12 @@ public class TestChRootedFs {
// Create file
- FileContextTestHelper.createFileNonRecursive(fc, "/foo");
+ fileContextTestHelper.createFileNonRecursive(fc, "/foo");
Assert.assertTrue(isFile(fc, new Path("/foo")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo, "foo")));
// Create file with recursive dir
- FileContextTestHelper.createFile(fc, "/newDir/foo");
+ fileContextTestHelper.createFile(fc, "/newDir/foo");
Assert.assertTrue(isFile(fc, new Path("/newDir/foo")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/foo")));
@@ -120,7 +121,7 @@ public class TestChRootedFs {
Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
// Create file with a 2 component dirs recursively
- FileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
+ fileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
Assert.assertTrue(isFile(fc, new Path("/newDir/newDir2/foo")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo")));
@@ -133,11 +134,11 @@ public class TestChRootedFs {
@Test
public void testMkdirDelete() throws IOException {
- fc.mkdir(FileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
Assert.assertTrue(isDir(fc, new Path("/dirX")));
Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX")));
- fc.mkdir(FileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
Assert.assertTrue(isDir(fc, new Path("/dirX/dirY")));
Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX/dirY")));
@@ -155,11 +156,11 @@ public class TestChRootedFs {
@Test
public void testRename() throws IOException {
// Rename a file
- FileContextTestHelper.createFile(fc, "/newDir/foo");
+ fileContextTestHelper.createFile(fc, "/newDir/foo");
fc.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
Assert.assertFalse(exists(fc, new Path("/newDir/foo")));
Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
- Assert.assertTrue(isFile(fc, FileContextTestHelper.getTestRootPath(fc,"/newDir/fooBar")));
+ Assert.assertTrue(isFile(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/fooBar")));
Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/fooBar")));
@@ -168,7 +169,7 @@ public class TestChRootedFs {
fc.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
Assert.assertFalse(exists(fc, new Path("/newDir/dirFoo")));
Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/dirFoo")));
- Assert.assertTrue(isDir(fc, FileContextTestHelper.getTestRootPath(fc,"/newDir/dirFooBar")));
+ Assert.assertTrue(isDir(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/dirFooBar")));
Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"newDir/dirFooBar")));
}
@@ -202,10 +203,10 @@ public class TestChRootedFs {
- FileContextTestHelper.createFileNonRecursive(fc, "/foo");
- FileContextTestHelper.createFileNonRecursive(fc, "/bar");
+ fileContextTestHelper.createFileNonRecursive(fc, "/foo");
+ fileContextTestHelper.createFileNonRecursive(fc, "/bar");
fc.mkdir(new Path("/dirX"), FileContext.DEFAULT_PERM, false);
- fc.mkdir(FileContextTestHelper.getTestRootPath(fc, "/dirY"),
+ fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirY"),
FileContext.DEFAULT_PERM, false);
fc.mkdir(new Path("/dirX/dirXX"), FileContext.DEFAULT_PERM, false);
@@ -213,16 +214,16 @@ public class TestChRootedFs {
Assert.assertEquals(4, dirPaths.length);
// Note the the file status paths are the full paths on target
- fs = FileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isFile());
- fs = FileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isFile());
- fs = FileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isDirectory());
- fs = FileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue(fs.isDirectory());
}
@@ -273,7 +274,7 @@ public class TestChRootedFs {
fc.mkdir(new Path("newDir"), FileContext.DEFAULT_PERM, true);
Assert.assertTrue(isDir(fc, new Path(absoluteDir, "newDir")));
- absoluteDir = getTestRootPath(fc, "nonexistingPath");
+ absoluteDir = fileContextTestHelper.getTestRootPath(fc, "nonexistingPath");
try {
fc.setWorkingDirectory(absoluteDir);
Assert.fail("cd to non existing dir should have failed");
@@ -297,7 +298,7 @@ public class TestChRootedFs {
@Test
public void testResolvePath() throws IOException {
Assert.assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/")));
- FileContextTestHelper.createFile(fc, "/foo");
+ fileContextTestHelper.createFile(fc, "/foo");
Assert.assertEquals(new Path(chrootedTo, "foo"),
fc.getDefaultFileSystem().resolvePath(new Path("/foo")));
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
index de4b1e87ac5..6081f385706 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSMainOperationsBaseTest;
-import org.apache.hadoop.fs.FileSystemTestHelper;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.After;
@@ -32,14 +31,19 @@ import org.junit.Before;
import org.junit.Test;
public class TestFSMainOperationsLocalFileSystem extends FSMainOperationsBaseTest {
- static FileSystem fcTarget;
+ FileSystem fcTarget;
+
+ @Override
+ protected FileSystem createFileSystem() throws Exception {
+ return ViewFileSystemTestSetup.setupForViewFileSystem(
+ ViewFileSystemTestSetup.createConfig(), this, fcTarget);
+ }
+
@Override
@Before
public void setUp() throws Exception {
Configuration conf = new Configuration();
fcTarget = FileSystem.getLocal(conf);
- fSys = ViewFileSystemTestSetup.setupForViewFileSystem(
- ViewFileSystemTestSetup.createConfig(), fcTarget);
super.setUp();
}
@@ -47,14 +51,13 @@ public class TestFSMainOperationsLocalFileSystem extends FSMainOperationsBaseTes
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFileSystemTestSetup.tearDown(fcTarget);
+ ViewFileSystemTestSetup.tearDown(this, fcTarget);
}
@Test
@Override
public void testWDAbsolute() throws IOException {
- Path absoluteDir = FileSystemTestHelper.getTestRootPath(fSys,
- "test/existingDir");
+ Path absoluteDir = getTestRootPath(fSys, "test/existingDir");
fSys.mkdirs(absoluteDir);
fSys.setWorkingDirectory(absoluteDir);
Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory());
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java
index 16b38b72ec1..79217b3f421 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java
@@ -31,7 +31,7 @@ public class TestFcCreateMkdirLocalFs extends
@Override
@Before
public void setUp() throws Exception {
- fc = ViewFsTestSetup.setupForViewFsLocalFs();
+ fc = ViewFsTestSetup.setupForViewFsLocalFs(fileContextTestHelper);
super.setUp();
}
@@ -39,6 +39,6 @@ public class TestFcCreateMkdirLocalFs extends
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFsTestSetup.tearDownForViewFsLocalFs();
+ ViewFsTestSetup.tearDownForViewFsLocalFs(fileContextTestHelper);
}
}
\ No newline at end of file
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java
index 74f558509f1..61e0322491a 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java
@@ -39,7 +39,7 @@ public class TestFcMainOperationsLocalFs extends
@Override
@Before
public void setUp() throws Exception {
- fc = ViewFsTestSetup.setupForViewFsLocalFs();
+ fc = ViewFsTestSetup.setupForViewFsLocalFs(fileContextTestHelper);
super.setUp();
}
@@ -47,6 +47,6 @@ public class TestFcMainOperationsLocalFs extends
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFsTestSetup.tearDownForViewFsLocalFs();
+ ViewFsTestSetup.tearDownForViewFsLocalFs(fileContextTestHelper);
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java
index 0e44be9be85..afbbd635e9f 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.fs.viewfs;
+import org.apache.hadoop.fs.FileContext;
import org.apache.hadoop.fs.FileContextPermissionBase;
import org.junit.After;
@@ -26,11 +27,9 @@ import org.junit.Before;
public class TestFcPermissionsLocalFs extends FileContextPermissionBase {
-
@Override
@Before
public void setUp() throws Exception {
- fc = ViewFsTestSetup.setupForViewFsLocalFs();
super.setUp();
}
@@ -38,6 +37,11 @@ public class TestFcPermissionsLocalFs extends FileContextPermissionBase {
@After
public void tearDown() throws Exception {
super.tearDown();
- ViewFsTestSetup.tearDownForViewFsLocalFs();
+ ViewFsTestSetup.tearDownForViewFsLocalFs(fileContextTestHelper);
+ }
+
+ @Override
+ protected FileContext getFileContext() throws Exception {
+ return ViewFsTestSetup.setupForViewFsLocalFs(fileContextTestHelper);
}
}
\ No newline at end of file
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java
index e320f87bbce..487ce91a078 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java
@@ -52,7 +52,7 @@ public class TestViewFileSystemDelegation { //extends ViewFileSystemTestSetup {
conf.set("fs."+scheme+".impl", clazz.getName());
FakeFileSystem fs = (FakeFileSystem)FileSystem.get(uri, conf);
assertEquals(uri, fs.getUri());
- Path targetPath = FileSystemTestHelper.getAbsoluteTestRootPath(fs);
+ Path targetPath = new FileSystemTestHelper().getAbsoluteTestRootPath(fs);
ConfigUtil.addLink(conf, "/mounts/"+scheme, targetPath.toUri());
return fs;
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java
index 4b45fc8c5b8..49437924ea3 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java
@@ -38,7 +38,6 @@ import org.junit.Before;
public class TestViewFileSystemLocalFileSystem extends ViewFileSystemBaseTest {
-
@Override
@Before
public void setUp() throws Exception {
@@ -51,7 +50,7 @@ public class TestViewFileSystemLocalFileSystem extends ViewFileSystemBaseTest {
@Override
@After
public void tearDown() throws Exception {
- fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);
+ fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
super.tearDown();
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java
index 4786cd5fdf5..877c2228c1e 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java
@@ -59,7 +59,7 @@ public class TestViewFileSystemWithAuthorityLocalFileSystem extends ViewFileSyst
@Override
@After
public void tearDown() throws Exception {
- fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);
+ fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
super.tearDown();
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
index 4325f403462..62ef9d14638 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
@@ -35,11 +35,12 @@ public class TestViewFsTrash {
FileSystem fsTarget; // the target file system - the mount will point here
FileSystem fsView;
Configuration conf;
+ FileSystemTestHelper fileSystemTestHelper = new FileSystemTestHelper();
- static class TestLFS extends LocalFileSystem {
+ class TestLFS extends LocalFileSystem {
Path home;
TestLFS() throws IOException {
- this(new Path(FileSystemTestHelper.TEST_ROOT_DIR));
+ this(new Path(fileSystemTestHelper.getTestRootDir()));
}
TestLFS(Path home) throws IOException {
super();
@@ -54,23 +55,23 @@ public class TestViewFsTrash {
@Before
public void setUp() throws Exception {
fsTarget = FileSystem.getLocal(new Configuration());
- fsTarget.mkdirs(new Path(FileSystemTestHelper.
+ fsTarget.mkdirs(new Path(fileSystemTestHelper.
getTestRootPath(fsTarget), "dir1"));
conf = ViewFileSystemTestSetup.createConfig();
- fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fsTarget);
+ fsView = ViewFileSystemTestSetup.setupForViewFileSystem(conf, fileSystemTestHelper, fsTarget);
conf.set("fs.defaultFS", FsConstants.VIEWFS_URI.toString());
}
@After
public void tearDown() throws Exception {
- ViewFileSystemTestSetup.tearDown(fsTarget);
+ ViewFileSystemTestSetup.tearDown(fileSystemTestHelper, fsTarget);
fsTarget.delete(new Path(fsTarget.getHomeDirectory(), ".Trash/Current"),
true);
}
@Test
public void testTrash() throws IOException {
- TestTrash.trashShell(conf, FileSystemTestHelper.getTestRootPath(fsView),
+ TestTrash.trashShell(conf, fileSystemTestHelper.getTestRootPath(fsView),
fsTarget, new Path(fsTarget.getHomeDirectory(), ".Trash/Current"));
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
index f59e3ab4526..e5fcef7e4de 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
@@ -68,7 +68,15 @@ public class ViewFileSystemBaseTest {
FileSystem fsTarget; // the target file system - the mount will point here
Path targetTestRoot;
Configuration conf;
+ final FileSystemTestHelper fileSystemTestHelper;
+ public ViewFileSystemBaseTest() {
+ this.fileSystemTestHelper = createFileSystemHelper();
+ }
+
+ protected FileSystemTestHelper createFileSystemHelper() {
+ return new FileSystemTestHelper();
+ }
@Before
public void setUp() throws Exception {
@@ -94,11 +102,11 @@ public class ViewFileSystemBaseTest {
@After
public void tearDown() throws Exception {
- fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);
+ fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
}
void initializeTargetTestRoot() throws IOException {
- targetTestRoot = FileSystemTestHelper.getAbsoluteTestRootPath(fsTarget);
+ targetTestRoot = fileSystemTestHelper.getAbsoluteTestRootPath(fsTarget);
// In case previous test was killed before cleanup
fsTarget.delete(targetTestRoot, true);
@@ -199,7 +207,7 @@ public class ViewFileSystemBaseTest {
@Test
public void testOperationsThroughMountLinks() throws IOException {
// Create file
- FileSystemTestHelper.createFile(fsView, "/user/foo");
+ fileSystemTestHelper.createFile(fsView, "/user/foo");
Assert.assertTrue("Created file should be type file",
fsView.isFile(new Path("/user/foo")));
Assert.assertTrue("Target of created file should be type file",
@@ -214,7 +222,7 @@ public class ViewFileSystemBaseTest {
fsTarget.exists(new Path(targetTestRoot,"user/foo")));
// Create file with a 2 component dirs
- FileSystemTestHelper.createFile(fsView, "/internalDir/linkToDir2/foo");
+ fileSystemTestHelper.createFile(fsView, "/internalDir/linkToDir2/foo");
Assert.assertTrue("Created file should be type file",
fsView.isFile(new Path("/internalDir/linkToDir2/foo")));
Assert.assertTrue("Target of created file should be type file",
@@ -230,14 +238,14 @@ public class ViewFileSystemBaseTest {
// Create file with a 3 component dirs
- FileSystemTestHelper.createFile(fsView, "/internalDir/internalDir2/linkToDir3/foo");
+ fileSystemTestHelper.createFile(fsView, "/internalDir/internalDir2/linkToDir3/foo");
Assert.assertTrue("Created file should be type file",
fsView.isFile(new Path("/internalDir/internalDir2/linkToDir3/foo")));
Assert.assertTrue("Target of created file should be type file",
fsTarget.isFile(new Path(targetTestRoot,"dir3/foo")));
// Recursive Create file with missing dirs
- FileSystemTestHelper.createFile(fsView,
+ fileSystemTestHelper.createFile(fsView,
"/internalDir/linkToDir2/missingDir/miss2/foo");
Assert.assertTrue("Created file should be type file",
fsView.isFile(new Path("/internalDir/linkToDir2/missingDir/miss2/foo")));
@@ -256,14 +264,14 @@ public class ViewFileSystemBaseTest {
// mkdir
- fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
+ fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
Assert.assertTrue("New dir should be type dir",
fsView.isDirectory(new Path("/user/dirX")));
Assert.assertTrue("Target of new dir should be of type dir",
fsTarget.isDirectory(new Path(targetTestRoot,"user/dirX")));
fsView.mkdirs(
- FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
+ fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
Assert.assertTrue("New dir should be type dir",
fsView.isDirectory(new Path("/user/dirX/dirY")));
Assert.assertTrue("Target of new dir should be of type dir",
@@ -285,14 +293,14 @@ public class ViewFileSystemBaseTest {
Assert.assertFalse(fsTarget.exists(new Path(targetTestRoot,"user/dirX")));
// Rename a file
- FileSystemTestHelper.createFile(fsView, "/user/foo");
+ fileSystemTestHelper.createFile(fsView, "/user/foo");
fsView.rename(new Path("/user/foo"), new Path("/user/fooBar"));
Assert.assertFalse("Renamed src should not exist",
fsView.exists(new Path("/user/foo")));
Assert.assertFalse("Renamed src should not exist in target",
fsTarget.exists(new Path(targetTestRoot,"user/foo")));
Assert.assertTrue("Renamed dest should exist as file",
- fsView.isFile(FileSystemTestHelper.getTestRootPath(fsView,"/user/fooBar")));
+ fsView.isFile(fileSystemTestHelper.getTestRootPath(fsView,"/user/fooBar")));
Assert.assertTrue("Renamed dest should exist as file in target",
fsTarget.isFile(new Path(targetTestRoot,"user/fooBar")));
@@ -303,7 +311,7 @@ public class ViewFileSystemBaseTest {
Assert.assertFalse("Renamed src should not exist in target",
fsTarget.exists(new Path(targetTestRoot,"user/dirFoo")));
Assert.assertTrue("Renamed dest should exist as dir",
- fsView.isDirectory(FileSystemTestHelper.getTestRootPath(fsView,"/user/dirFooBar")));
+ fsView.isDirectory(fileSystemTestHelper.getTestRootPath(fsView,"/user/dirFooBar")));
Assert.assertTrue("Renamed dest should exist as dir in target",
fsTarget.isDirectory(new Path(targetTestRoot,"user/dirFooBar")));
@@ -322,7 +330,7 @@ public class ViewFileSystemBaseTest {
// rename across mount points that point to same target also fail
@Test(expected=IOException.class)
public void testRenameAcrossMounts1() throws IOException {
- FileSystemTestHelper.createFile(fsView, "/user/foo");
+ fileSystemTestHelper.createFile(fsView, "/user/foo");
fsView.rename(new Path("/user/foo"), new Path("/user2/fooBarBar"));
/* - code if we had wanted this to suceed
Assert.assertFalse(fSys.exists(new Path("/user/foo")));
@@ -338,7 +346,7 @@ public class ViewFileSystemBaseTest {
@Test(expected=IOException.class)
public void testRenameAcrossMounts2() throws IOException {
- FileSystemTestHelper.createFile(fsView, "/user/foo");
+ fileSystemTestHelper.createFile(fsView, "/user/foo");
fsView.rename(new Path("/user/foo"), new Path("/data/fooBar"));
}
@@ -394,19 +402,19 @@ public class ViewFileSystemBaseTest {
FileStatus[] dirPaths = fsView.listStatus(new Path("/"));
FileStatus fs;
Assert.assertEquals(getExpectedDirPaths(), dirPaths.length);
- fs = FileSystemTestHelper.containsPath(fsView, "/user", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/user", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
- fs = FileSystemTestHelper.containsPath(fsView, "/data", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/data", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
- fs = FileSystemTestHelper.containsPath(fsView, "/internalDir", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/internalDir", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
- fs = FileSystemTestHelper.containsPath(fsView, "/danglingLink", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/danglingLink", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
- fs = FileSystemTestHelper.containsPath(fsView, "/linkToAFile", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/linkToAFile", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
@@ -416,10 +424,10 @@ public class ViewFileSystemBaseTest {
dirPaths = fsView.listStatus(new Path("/internalDir"));
Assert.assertEquals(2, dirPaths.length);
- fs = FileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
- fs = FileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2",
+ fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2",
dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
@@ -436,22 +444,22 @@ public class ViewFileSystemBaseTest {
Assert.assertEquals(0, dirPaths.length);
// add a file
- long len = FileSystemTestHelper.createFile(fsView, "/data/foo");
+ long len = fileSystemTestHelper.createFile(fsView, "/data/foo");
dirPaths = fsView.listStatus(new Path("/data"));
Assert.assertEquals(1, dirPaths.length);
- fs = FileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("Created file shoudl appear as a file", fs.isFile());
Assert.assertEquals(len, fs.getLen());
// add a dir
- fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/data/dirX"));
+ fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/data/dirX"));
dirPaths = fsView.listStatus(new Path("/data"));
Assert.assertEquals(2, dirPaths.length);
- fs = FileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("Created file shoudl appear as a file", fs.isFile());
- fs = FileSystemTestHelper.containsPath(fsView, "/data/dirX", dirPaths);
+ fs = fileSystemTestHelper.containsPath(fsView, "/data/dirX", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("Created dir should appear as a dir", fs.isDirectory());
}
@@ -487,12 +495,12 @@ public class ViewFileSystemBaseTest {
public void testResolvePathInternalPaths() throws IOException {
Assert.assertEquals(new Path("/"), fsView.resolvePath(new Path("/")));
Assert.assertEquals(new Path("/internalDir"),
- fsView.resolvePath(new Path("/internalDir")));
+ fsView.resolvePath(new Path("/internalDir")));
}
@Test
public void testResolvePathMountPoints() throws IOException {
Assert.assertEquals(new Path(targetTestRoot,"user"),
- fsView.resolvePath(new Path("/user")));
+ fsView.resolvePath(new Path("/user")));
Assert.assertEquals(new Path(targetTestRoot,"data"),
fsView.resolvePath(new Path("/data")));
Assert.assertEquals(new Path(targetTestRoot,"dir2"),
@@ -504,25 +512,25 @@ public class ViewFileSystemBaseTest {
@Test
public void testResolvePathThroughMountPoints() throws IOException {
- FileSystemTestHelper.createFile(fsView, "/user/foo");
+ fileSystemTestHelper.createFile(fsView, "/user/foo");
Assert.assertEquals(new Path(targetTestRoot,"user/foo"),
- fsView.resolvePath(new Path("/user/foo")));
+ fsView.resolvePath(new Path("/user/foo")));
fsView.mkdirs(
- FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
+ fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
Assert.assertEquals(new Path(targetTestRoot,"user/dirX"),
fsView.resolvePath(new Path("/user/dirX")));
fsView.mkdirs(
- FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
+ fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX/dirY"));
Assert.assertEquals(new Path(targetTestRoot,"user/dirX/dirY"),
fsView.resolvePath(new Path("/user/dirX/dirY")));
}
@Test(expected=FileNotFoundException.class)
public void testResolvePathDanglingLink() throws IOException {
- fsView.resolvePath(new Path("/danglingLink"));
+ fsView.resolvePath(new Path("/danglingLink"));
}
@Test(expected=FileNotFoundException.class)
@@ -534,7 +542,7 @@ public class ViewFileSystemBaseTest {
@Test(expected=FileNotFoundException.class)
public void testResolvePathMissingThroughMountPoints2() throws IOException {
fsView.mkdirs(
- FileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
+ fileSystemTestHelper.getTestRootPath(fsView, "/user/dirX"));
fsView.resolvePath(new Path("/user/dirX/nonExisting"));
}
@@ -550,76 +558,76 @@ public class ViewFileSystemBaseTest {
// Mkdir on existing internal mount table succeed except for /
@Test(expected=AccessControlException.class)
public void testInternalMkdirSlash() throws IOException {
- fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/"));
+ fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/"));
}
public void testInternalMkdirExisting1() throws IOException {
Assert.assertTrue("mkdir of existing dir should succeed",
- fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView,
+ fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView,
"/internalDir")));
}
public void testInternalMkdirExisting2() throws IOException {
Assert.assertTrue("mkdir of existing dir should succeed",
- fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView,
+ fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView,
"/internalDir/linkToDir2")));
}
// Mkdir for new internal mount table should fail
@Test(expected=AccessControlException.class)
public void testInternalMkdirNew() throws IOException {
- fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/dirNew"));
+ fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/dirNew"));
}
@Test(expected=AccessControlException.class)
public void testInternalMkdirNew2() throws IOException {
- fsView.mkdirs(FileSystemTestHelper.getTestRootPath(fsView, "/internalDir/dirNew"));
+ fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/internalDir/dirNew"));
}
// Create File on internal mount table should fail
@Test(expected=AccessControlException.class)
public void testInternalCreate1() throws IOException {
- FileSystemTestHelper.createFile(fsView, "/foo"); // 1 component
+ fileSystemTestHelper.createFile(fsView, "/foo"); // 1 component
}
@Test(expected=AccessControlException.class)
public void testInternalCreate2() throws IOException { // 2 component
- FileSystemTestHelper.createFile(fsView, "/internalDir/foo");
+ fileSystemTestHelper.createFile(fsView, "/internalDir/foo");
}
@Test(expected=AccessControlException.class)
public void testInternalCreateMissingDir() throws IOException {
- FileSystemTestHelper.createFile(fsView, "/missingDir/foo");
+ fileSystemTestHelper.createFile(fsView, "/missingDir/foo");
}
@Test(expected=AccessControlException.class)
public void testInternalCreateMissingDir2() throws IOException {
- FileSystemTestHelper.createFile(fsView, "/missingDir/miss2/foo");
+ fileSystemTestHelper.createFile(fsView, "/missingDir/miss2/foo");
}
@Test(expected=AccessControlException.class)
public void testInternalCreateMissingDir3() throws IOException {
- FileSystemTestHelper.createFile(fsView, "/internalDir/miss2/foo");
+ fileSystemTestHelper.createFile(fsView, "/internalDir/miss2/foo");
}
// Delete on internal mount table should fail
@Test(expected=FileNotFoundException.class)
public void testInternalDeleteNonExisting() throws IOException {
- fsView.delete(new Path("/NonExisting"), false);
+ fsView.delete(new Path("/NonExisting"), false);
}
@Test(expected=FileNotFoundException.class)
public void testInternalDeleteNonExisting2() throws IOException {
- fsView.delete(new Path("/internalDir/NonExisting"), false);
+ fsView.delete(new Path("/internalDir/NonExisting"), false);
}
@Test(expected=AccessControlException.class)
public void testInternalDeleteExisting() throws IOException {
- fsView.delete(new Path("/internalDir"), false);
+ fsView.delete(new Path("/internalDir"), false);
}
@Test(expected=AccessControlException.class)
public void testInternalDeleteExisting2() throws IOException {
- fsView.getFileStatus(
+ fsView.getFileStatus(
new Path("/internalDir/linkToDir2")).isDirectory();
fsView.delete(new Path("/internalDir/linkToDir2"), false);
}
@@ -641,7 +649,7 @@ public class ViewFileSystemBaseTest {
}
@Test(expected=AccessControlException.class)
public void testInternalRename2() throws IOException {
- fsView.getFileStatus(new Path("/internalDir/linkToDir2")).isDirectory();
+ fsView.getFileStatus(new Path("/internalDir/linkToDir2")).isDirectory();
fsView.rename(new Path("/internalDir/linkToDir2"),
new Path("/internalDir/dir1"));
}
@@ -665,7 +673,7 @@ public class ViewFileSystemBaseTest {
@Test
public void testCreateNonRecursive() throws IOException {
- Path path = FileSystemTestHelper.getTestRootPath(fsView, "/user/foo");
+ Path path = fileSystemTestHelper.getTestRootPath(fsView, "/user/foo");
fsView.createNonRecursive(path, false, 1024, (short)1, 1024L, null);
FileStatus status = fsView.getFileStatus(new Path("/user/foo"));
Assert.assertTrue("Created file should be type file",
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
index 446b38e60b8..07bd0ce6e09 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemTestSetup.java
@@ -55,18 +55,18 @@ public class ViewFileSystemTestSetup {
* @return return the ViewFS File context to be used for tests
* @throws Exception
*/
- static public FileSystem setupForViewFileSystem(Configuration conf, FileSystem fsTarget) throws Exception {
+ static public FileSystem setupForViewFileSystem(Configuration conf, FileSystemTestHelper fileSystemTestHelper, FileSystem fsTarget) throws Exception {
/**
* create the test root on local_fs - the mount table will point here
*/
- Path targetOfTests = FileSystemTestHelper.getTestRootPath(fsTarget);
+ Path targetOfTests = fileSystemTestHelper.getTestRootPath(fsTarget);
// In case previous test was killed before cleanup
fsTarget.delete(targetOfTests, true);
fsTarget.mkdirs(targetOfTests);
// Set up viewfs link for test dir as described above
- String testDir = FileSystemTestHelper.getTestRootPath(fsTarget).toUri()
+ String testDir = fileSystemTestHelper.getTestRootPath(fsTarget).toUri()
.getPath();
linkUpFirstComponents(conf, testDir, fsTarget, "test dir");
@@ -91,14 +91,21 @@ public class ViewFileSystemTestSetup {
*
* delete the test directory in the target fs
*/
- static public void tearDown(FileSystem fsTarget) throws Exception {
- Path targetOfTests = FileSystemTestHelper.getTestRootPath(fsTarget);
+ static public void tearDown(FileSystemTestHelper fileSystemTestHelper, FileSystem fsTarget) throws Exception {
+ Path targetOfTests = fileSystemTestHelper.getTestRootPath(fsTarget);
fsTarget.delete(targetOfTests, true);
}
public static Configuration createConfig() {
+ return createConfig(true);
+ }
+
+ public static Configuration createConfig(boolean disableCache) {
Configuration conf = new Configuration();
conf.set("fs.viewfs.impl", ViewFileSystem.class.getName());
+ if (disableCache) {
+ conf.set("fs.viewfs.impl.disable.cache", "true");
+ }
return conf;
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
index 7f731de23e9..71894e6da97 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
@@ -75,6 +75,7 @@ public class ViewFsBaseTest {
Configuration conf;
FileContext xfcViewWithAuthority; // same as fsView but with authority
URI schemeWithAuthority;
+ final FileContextTestHelper fileContextTestHelper = new FileContextTestHelper();
@Before
public void setUp() throws Exception {
@@ -118,7 +119,7 @@ public class ViewFsBaseTest {
}
void initializeTargetTestRoot() throws IOException {
- targetTestRoot = FileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
+ targetTestRoot = fileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
// In case previous test was killed before cleanup
fcTarget.delete(targetTestRoot, true);
@@ -127,7 +128,7 @@ public class ViewFsBaseTest {
@After
public void tearDown() throws Exception {
- fcTarget.delete(FileContextTestHelper.getTestRootPath(fcTarget), true);
+ fcTarget.delete(fileContextTestHelper.getTestRootPath(fcTarget), true);
}
@Test
@@ -181,7 +182,7 @@ public class ViewFsBaseTest {
@Test
public void testOperationsThroughMountLinks() throws IOException {
// Create file
- FileContextTestHelper.createFileNonRecursive(fcView, "/user/foo");
+ fileContextTestHelper.createFileNonRecursive(fcView, "/user/foo");
Assert.assertTrue("Create file should be file",
isFile(fcView, new Path("/user/foo")));
Assert.assertTrue("Target of created file should be type file",
@@ -196,7 +197,7 @@ public class ViewFsBaseTest {
exists(fcTarget, new Path(targetTestRoot,"user/foo")));
// Create file with a 2 component dirs
- FileContextTestHelper.createFileNonRecursive(fcView,
+ fileContextTestHelper.createFileNonRecursive(fcView,
"/internalDir/linkToDir2/foo");
Assert.assertTrue("Created file should be type file",
isFile(fcView, new Path("/internalDir/linkToDir2/foo")));
@@ -213,7 +214,7 @@ public class ViewFsBaseTest {
// Create file with a 3 component dirs
- FileContextTestHelper.createFileNonRecursive(fcView,
+ fileContextTestHelper.createFileNonRecursive(fcView,
"/internalDir/internalDir2/linkToDir3/foo");
Assert.assertTrue("Created file should be of type file",
isFile(fcView, new Path("/internalDir/internalDir2/linkToDir3/foo")));
@@ -221,7 +222,7 @@ public class ViewFsBaseTest {
isFile(fcTarget, new Path(targetTestRoot,"dir3/foo")));
// Recursive Create file with missing dirs
- FileContextTestHelper.createFile(fcView,
+ fileContextTestHelper.createFile(fcView,
"/internalDir/linkToDir2/missingDir/miss2/foo");
Assert.assertTrue("Created file should be of type file",
isFile(fcView, new Path("/internalDir/linkToDir2/missingDir/miss2/foo")));
@@ -239,14 +240,14 @@ public class ViewFsBaseTest {
// mkdir
- fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
+ fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
FileContext.DEFAULT_PERM, false);
Assert.assertTrue("New dir should be type dir",
isDir(fcView, new Path("/user/dirX")));
Assert.assertTrue("Target of new dir should be of type dir",
isDir(fcTarget, new Path(targetTestRoot,"user/dirX")));
- fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
+ fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
FileContext.DEFAULT_PERM, false);
Assert.assertTrue("New dir should be type dir",
isDir(fcView, new Path("/user/dirX/dirY")));
@@ -270,13 +271,13 @@ public class ViewFsBaseTest {
exists(fcTarget, new Path(targetTestRoot,"user/dirX")));
// Rename a file
- FileContextTestHelper.createFile(fcView, "/user/foo");
+ fileContextTestHelper.createFile(fcView, "/user/foo");
fcView.rename(new Path("/user/foo"), new Path("/user/fooBar"));
Assert.assertFalse("Renamed src should not exist",
exists(fcView, new Path("/user/foo")));
Assert.assertFalse(exists(fcTarget, new Path(targetTestRoot,"user/foo")));
Assert.assertTrue(isFile(fcView,
- FileContextTestHelper.getTestRootPath(fcView,"/user/fooBar")));
+ fileContextTestHelper.getTestRootPath(fcView,"/user/fooBar")));
Assert.assertTrue(isFile(fcTarget, new Path(targetTestRoot,"user/fooBar")));
fcView.mkdir(new Path("/user/dirFoo"), FileContext.DEFAULT_PERM, false);
@@ -287,7 +288,7 @@ public class ViewFsBaseTest {
exists(fcTarget, new Path(targetTestRoot,"user/dirFoo")));
Assert.assertTrue("Renamed dest should exist as dir",
isDir(fcView,
- FileContextTestHelper.getTestRootPath(fcView,"/user/dirFooBar")));
+ fileContextTestHelper.getTestRootPath(fcView,"/user/dirFooBar")));
Assert.assertTrue("Renamed dest should exist as dir in target",
isDir(fcTarget,new Path(targetTestRoot,"user/dirFooBar")));
@@ -309,7 +310,7 @@ public class ViewFsBaseTest {
// rename across mount points that point to same target also fail
@Test(expected=IOException.class)
public void testRenameAcrossMounts1() throws IOException {
- FileContextTestHelper.createFile(fcView, "/user/foo");
+ fileContextTestHelper.createFile(fcView, "/user/foo");
fcView.rename(new Path("/user/foo"), new Path("/user2/fooBarBar"));
/* - code if we had wanted this to succeed
Assert.assertFalse(exists(fc, new Path("/user/foo")));
@@ -327,7 +328,7 @@ public class ViewFsBaseTest {
@Test(expected=IOException.class)
public void testRenameAcrossMounts2() throws IOException {
- FileContextTestHelper.createFile(fcView, "/user/foo");
+ fileContextTestHelper.createFile(fcView, "/user/foo");
fcView.rename(new Path("/user/foo"), new Path("/data/fooBar"));
}
@@ -382,19 +383,19 @@ public class ViewFsBaseTest {
FileStatus[] dirPaths = fcView.util().listStatus(new Path("/"));
FileStatus fs;
Assert.assertEquals(7, dirPaths.length);
- fs = FileContextTestHelper.containsPath(fcView, "/user", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcView, "/user", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
- fs = FileContextTestHelper.containsPath(fcView, "/data", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcView, "/data", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
- fs = FileContextTestHelper.containsPath(fcView, "/internalDir", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcView, "/internalDir", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("InternalDirs should appear as dir", fs.isDirectory());
- fs = FileContextTestHelper.containsPath(fcView, "/danglingLink", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcView, "/danglingLink", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
- fs = FileContextTestHelper.containsPath(fcView, "/linkToAFile", dirPaths);
+ fs = fileContextTestHelper.containsPath(fcView, "/linkToAFile", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
@@ -404,11 +405,11 @@ public class ViewFsBaseTest {
dirPaths = fcView.util().listStatus(new Path("/internalDir"));
Assert.assertEquals(2, dirPaths.length);
- fs = FileContextTestHelper.containsPath(fcView,
+ fs = fileContextTestHelper.containsPath(fcView,
"/internalDir/internalDir2", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("InternalDirs should appear as dir",fs.isDirectory());
- fs = FileContextTestHelper.containsPath(fcView,
+ fs = fileContextTestHelper.containsPath(fcView,
"/internalDir/linkToDir2", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
@@ -534,19 +535,19 @@ public class ViewFsBaseTest {
@Test
public void testResolvePathThroughMountPoints() throws IOException {
- FileContextTestHelper.createFile(fcView, "/user/foo");
+ fileContextTestHelper.createFile(fcView, "/user/foo");
Assert.assertEquals(new Path(targetTestRoot,"user/foo"),
fcView.resolvePath(new Path("/user/foo")));
fcView.mkdir(
- FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
+ fileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
FileContext.DEFAULT_PERM, false);
Assert.assertEquals(new Path(targetTestRoot,"user/dirX"),
fcView.resolvePath(new Path("/user/dirX")));
fcView.mkdir(
- FileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
+ fileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
FileContext.DEFAULT_PERM, false);
Assert.assertEquals(new Path(targetTestRoot,"user/dirX/dirY"),
fcView.resolvePath(new Path("/user/dirX/dirY")));
@@ -566,7 +567,7 @@ public class ViewFsBaseTest {
@Test(expected=FileNotFoundException.class)
public void testResolvePathMissingThroughMountPoints2() throws IOException {
fcView.mkdir(
- FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
+ fileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
FileContext.DEFAULT_PERM, false);
fcView.resolvePath(new Path("/user/dirX/nonExisting"));
}
@@ -584,29 +585,29 @@ public class ViewFsBaseTest {
// Mkdir on internal mount table should fail
@Test(expected=AccessControlException.class)
public void testInternalMkdirSlash() throws IOException {
- fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/"),
+ fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/"),
FileContext.DEFAULT_PERM, false);
}
@Test(expected=AccessControlException.class)
public void testInternalMkdirExisting1() throws IOException {
- fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/internalDir"),
+ fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/internalDir"),
FileContext.DEFAULT_PERM, false);
}
@Test(expected=AccessControlException.class)
public void testInternalMkdirExisting2() throws IOException {
- fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView,
+ fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView,
"/internalDir/linkToDir2"),
FileContext.DEFAULT_PERM, false);
}
@Test(expected=AccessControlException.class)
public void testInternalMkdirNew() throws IOException {
- fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/dirNew"),
+ fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/dirNew"),
FileContext.DEFAULT_PERM, false);
}
@Test(expected=AccessControlException.class)
public void testInternalMkdirNew2() throws IOException {
- fcView.mkdir(FileContextTestHelper.getTestRootPath(fcView, "/internalDir/dirNew"),
+ fcView.mkdir(fileContextTestHelper.getTestRootPath(fcView, "/internalDir/dirNew"),
FileContext.DEFAULT_PERM, false);
}
@@ -614,28 +615,28 @@ public class ViewFsBaseTest {
@Test(expected=AccessControlException.class)
public void testInternalCreate1() throws IOException {
- FileContextTestHelper.createFileNonRecursive(fcView, "/foo"); // 1 component
+ fileContextTestHelper.createFileNonRecursive(fcView, "/foo"); // 1 component
}
@Test(expected=AccessControlException.class)
public void testInternalCreate2() throws IOException { // 2 component
- FileContextTestHelper.createFileNonRecursive(fcView, "/internalDir/foo");
+ fileContextTestHelper.createFileNonRecursive(fcView, "/internalDir/foo");
}
@Test(expected=AccessControlException.class)
public void testInternalCreateMissingDir() throws IOException {
- FileContextTestHelper.createFile(fcView, "/missingDir/foo");
+ fileContextTestHelper.createFile(fcView, "/missingDir/foo");
}
@Test(expected=AccessControlException.class)
public void testInternalCreateMissingDir2() throws IOException {
- FileContextTestHelper.createFile(fcView, "/missingDir/miss2/foo");
+ fileContextTestHelper.createFile(fcView, "/missingDir/miss2/foo");
}
@Test(expected=AccessControlException.class)
public void testInternalCreateMissingDir3() throws IOException {
- FileContextTestHelper.createFile(fcView, "/internalDir/miss2/foo");
+ fileContextTestHelper.createFile(fcView, "/internalDir/miss2/foo");
}
// Delete on internal mount table should fail
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java
index ac63217fd43..0dd83408173 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsTestSetup.java
@@ -53,12 +53,12 @@ public class ViewFsTestSetup {
/*
* return the ViewFS File context to be used for tests
*/
- static public FileContext setupForViewFsLocalFs() throws Exception {
+ static public FileContext setupForViewFsLocalFs(FileContextTestHelper helper) throws Exception {
/**
* create the test root on local_fs - the mount table will point here
*/
FileContext fsTarget = FileContext.getLocalFSFileContext();
- Path targetOfTests = FileContextTestHelper.getTestRootPath(fsTarget);
+ Path targetOfTests = helper.getTestRootPath(fsTarget);
// In case previous test was killed before cleanup
fsTarget.delete(targetOfTests, true);
@@ -66,7 +66,7 @@ public class ViewFsTestSetup {
Configuration conf = new Configuration();
// Set up viewfs link for test dir as described above
- String testDir = FileContextTestHelper.getTestRootPath(fsTarget).toUri()
+ String testDir = helper.getTestRootPath(fsTarget).toUri()
.getPath();
linkUpFirstComponents(conf, testDir, fsTarget, "test dir");
@@ -91,9 +91,9 @@ public class ViewFsTestSetup {
*
* delete the test directory in the target local fs
*/
- static public void tearDownForViewFsLocalFs() throws Exception {
+ static public void tearDownForViewFsLocalFs(FileContextTestHelper helper) throws Exception {
FileContext fclocal = FileContext.getLocalFSFileContext();
- Path targetOfTests = FileContextTestHelper.getTestRootPath(fclocal);
+ Path targetOfTests = helper.getTestRootPath(fclocal);
fclocal.delete(targetOfTests, true);
}
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 9c68b282f63..89af8d06f1a 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
@@ -23,7 +23,10 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.io.RandomAccessFile;
import java.net.Socket;
+import java.nio.channels.FileLock;
+import java.nio.channels.OverlappingFileLockException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -63,17 +66,13 @@ public abstract class ClientBaseWithFixes extends ZKTestCase {
static final File BASETEST =
new File(System.getProperty("build.test.dir", "build"));
- protected String hostPort = "127.0.0.1:" + PortAssignment.unique();
+ protected final String hostPort = initHostPort();
protected int maxCnxns = 0;
protected ServerCnxnFactory serverFactory = null;
protected File tmpDir = null;
long initialFdCount;
- public ClientBaseWithFixes() {
- super();
- }
-
/**
* In general don't use this. Only use in the special case that you
* want to ignore results (for whatever reason) in your test. Don't
@@ -154,6 +153,10 @@ public abstract class ClientBaseWithFixes extends ZKTestCase {
private LinkedList