use of org.apache.hadoop.fs.viewfs.ChRootedFs in project hadoop by apache.
the class TestChRootedFs method testIsValidNameInvalidInBaseFs.
@Test
public void testIsValidNameInvalidInBaseFs() throws Exception {
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString());
Assert.assertFalse(chRootedFs.isValidName("/test"));
Mockito.verify(baseFs).isValidName("/chroot/test");
}
use of org.apache.hadoop.fs.viewfs.ChRootedFs in project hadoop by apache.
the class TestChRootedFs method testRenameSnapshot.
@Test(timeout = 30000)
public void testRenameSnapshot() throws Exception {
Path snapRootPath = new Path("/snapPath");
Path chRootedSnapRootPath = new Path(Path.getPathWithoutSchemeAndAuthority(chrootedTo), "snapPath");
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
Mockito.doNothing().when(baseFs).renameSnapshot(chRootedSnapRootPath, "snapOldName", "snapNewName");
chRootedFs.renameSnapshot(snapRootPath, "snapOldName", "snapNewName");
Mockito.verify(baseFs).renameSnapshot(chRootedSnapRootPath, "snapOldName", "snapNewName");
}
use of org.apache.hadoop.fs.viewfs.ChRootedFs in project hadoop by apache.
the class TestChRootedFs method setUp.
@Before
public void setUp() throws Exception {
// create the test root on local_fs
fcTarget = FileContext.getLocalFSFileContext();
chrootedTo = fileContextTestHelper.getAbsoluteTestRootPath(fcTarget);
// In case previous test was killed before cleanup
fcTarget.delete(chrootedTo, true);
fcTarget.mkdir(chrootedTo, FileContext.DEFAULT_PERM, true);
Configuration conf = new Configuration();
// ChRoot to the root of the testDirectory
fc = FileContext.getFileContext(new ChRootedFs(fcTarget.getDefaultFileSystem(), chrootedTo), conf);
}
use of org.apache.hadoop.fs.viewfs.ChRootedFs in project hadoop by apache.
the class TestChRootedFs method testDeleteSnapshot.
@Test(timeout = 30000)
public void testDeleteSnapshot() throws Exception {
Path snapRootPath = new Path("/snapPath");
Path chRootedSnapRootPath = new Path(Path.getPathWithoutSchemeAndAuthority(chrootedTo), "snapPath");
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
Mockito.doNothing().when(baseFs).deleteSnapshot(chRootedSnapRootPath, "snap1");
chRootedFs.deleteSnapshot(snapRootPath, "snap1");
Mockito.verify(baseFs).deleteSnapshot(chRootedSnapRootPath, "snap1");
}
use of org.apache.hadoop.fs.viewfs.ChRootedFs in project hadoop by apache.
the class TestChRootedFs method testCreateSnapshot.
@Test(timeout = 30000)
public void testCreateSnapshot() throws Exception {
Path snapRootPath = new Path("/snapPath");
Path chRootedSnapRootPath = new Path(Path.getPathWithoutSchemeAndAuthority(chrootedTo), "snapPath");
AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
Mockito.doReturn(snapRootPath).when(baseFs).createSnapshot(chRootedSnapRootPath, "snap1");
Assert.assertEquals(snapRootPath, chRootedFs.createSnapshot(snapRootPath, "snap1"));
Mockito.verify(baseFs).createSnapshot(chRootedSnapRootPath, "snap1");
}
Aggregations