|
@@ -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",
|