Search in sources :

Example 1 with ChRootedFs

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");
}
Also used : AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) Path(org.apache.hadoop.fs.Path) ChRootedFs(org.apache.hadoop.fs.viewfs.ChRootedFs) Test(org.junit.Test)

Example 2 with ChRootedFs

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");
}
Also used : Path(org.apache.hadoop.fs.Path) AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) ChRootedFs(org.apache.hadoop.fs.viewfs.ChRootedFs) Test(org.junit.Test)

Example 3 with ChRootedFs

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) ChRootedFs(org.apache.hadoop.fs.viewfs.ChRootedFs) Before(org.junit.Before)

Example 4 with ChRootedFs

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");
}
Also used : Path(org.apache.hadoop.fs.Path) AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) ChRootedFs(org.apache.hadoop.fs.viewfs.ChRootedFs) Test(org.junit.Test)

Example 5 with ChRootedFs

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");
}
Also used : Path(org.apache.hadoop.fs.Path) AbstractFileSystem(org.apache.hadoop.fs.AbstractFileSystem) ChRootedFs(org.apache.hadoop.fs.viewfs.ChRootedFs) Test(org.junit.Test)

Aggregations

ChRootedFs (org.apache.hadoop.fs.viewfs.ChRootedFs)6 AbstractFileSystem (org.apache.hadoop.fs.AbstractFileSystem)5 Path (org.apache.hadoop.fs.Path)5 Test (org.junit.Test)5 Configuration (org.apache.hadoop.conf.Configuration)1 Before (org.junit.Before)1