Search in sources :

Example 26 with AccessControlException

use of alluxio.exception.AccessControlException in project alluxio by Alluxio.

the class ReadOnlyMountIntegrationTest method renameFile.

@Test
public void renameFile() throws IOException, AlluxioException {
    AlluxioURI srcUri = new AlluxioURI(FILE_PATH);
    AlluxioURI dstUri = new AlluxioURI(FILE_PATH + "_renamed");
    try {
        mFileSystem.rename(srcUri, dstUri);
        Assert.fail("rename should not succeed under a readonly mount.");
    } catch (AccessControlException e) {
        Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(srcUri, MOUNT_PATH)));
    }
    srcUri = new AlluxioURI(SUB_FILE_PATH);
    dstUri = new AlluxioURI(SUB_FILE_PATH + "_renamed");
    try {
        mFileSystem.rename(srcUri, dstUri);
        Assert.fail("rename should not succeed under a readonly mount.");
    } catch (AccessControlException e) {
        Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(srcUri, MOUNT_PATH)));
    }
}
Also used : AccessControlException(alluxio.exception.AccessControlException) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 27 with AccessControlException

use of alluxio.exception.AccessControlException in project alluxio by Alluxio.

the class ReadOnlyMountIntegrationTest method renameFileDst.

@Test
public void renameFileDst() throws IOException, AlluxioException {
    AlluxioURI srcUri = new AlluxioURI("/tmp");
    AlluxioURI dstUri = new AlluxioURI(FILE_PATH + "_renamed");
    try {
        mFileSystem.rename(srcUri, dstUri);
        Assert.fail("rename should not succeed under a readonly mount.");
    } catch (AccessControlException e) {
        Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(dstUri, MOUNT_PATH)));
    }
    dstUri = new AlluxioURI(SUB_FILE_PATH + "_renamed");
    try {
        mFileSystem.rename(srcUri, dstUri);
        Assert.fail("rename should not succeed under a readonly mount.");
    } catch (AccessControlException e) {
        Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(dstUri, MOUNT_PATH)));
    }
}
Also used : AccessControlException(alluxio.exception.AccessControlException) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 28 with AccessControlException

use of alluxio.exception.AccessControlException in project alluxio by Alluxio.

the class ReadOnlyMountIntegrationTest method chmod.

@Test
public void chmod() throws IOException, AlluxioException {
    AlluxioURI uri = new AlluxioURI(FILE_PATH + "_chmod");
    try {
        mFileSystem.setAttribute(uri, SetAttributePOptions.newBuilder().setMode(new Mode((short) 0555).toProto()).build());
        Assert.fail("chomd should not succeed under a readonly mount.");
    } catch (AccessControlException e) {
        Assert.assertThat(e.getMessage(), containsString(ExceptionMessage.MOUNT_READONLY.getMessage(uri, MOUNT_PATH)));
    }
}
Also used : Mode(alluxio.security.authorization.Mode) AccessControlException(alluxio.exception.AccessControlException) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 29 with AccessControlException

use of alluxio.exception.AccessControlException in project alluxio by Alluxio.

the class JournalCheckpointIntegrationTest method recoverUfsState.

@Test
public void recoverUfsState() throws Exception {
    FileSystemMasterClient client = new RetryHandlingFileSystemMasterClient(MasterClientContext.newBuilder(ClientContext.create(ServerConfiguration.global())).build());
    client.updateUfsMode(new AlluxioURI(""), UpdateUfsModePOptions.newBuilder().setUfsMode(UfsPMode.READ_ONLY).build());
    backupAndRestore();
    try {
        mCluster.getClient().createDirectory(new AlluxioURI("/test"), CreateDirectoryPOptions.newBuilder().setWriteType(WritePType.THROUGH).build());
        fail("Expected an exception to be thrown");
    } catch (AccessControlException e) {
    // Expected
    }
}
Also used : RetryHandlingFileSystemMasterClient(alluxio.client.file.RetryHandlingFileSystemMasterClient) FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) RetryHandlingFileSystemMasterClient(alluxio.client.file.RetryHandlingFileSystemMasterClient) AccessControlException(alluxio.exception.AccessControlException) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 30 with AccessControlException

use of alluxio.exception.AccessControlException in project alluxio by Alluxio.

the class MountTableTest method writableMount.

/**
 * Tests check of writable mount points.
 */
@Test
public void writableMount() throws Exception {
    String mountPath = "/mnt/foo";
    AlluxioURI alluxioUri = new AlluxioURI("alluxio://localhost:1234" + mountPath);
    addMount(alluxioUri.toString(), "hdfs://localhost:5678/foo", IdUtils.INVALID_MOUNT_ID);
    try {
        mMountTable.checkUnderWritableMountPoint(alluxioUri);
    } catch (AccessControlException e) {
        Assert.fail("Default mount point should be writable.");
    }
    try {
        String path = mountPath + "/sub/directory";
        alluxioUri = new AlluxioURI("alluxio://localhost:1234" + path);
        mMountTable.checkUnderWritableMountPoint(alluxioUri);
    } catch (AccessControlException e) {
        Assert.fail("Default mount point should be writable.");
    }
}
Also used : AccessControlException(alluxio.exception.AccessControlException) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AccessControlException (alluxio.exception.AccessControlException)64 AlluxioURI (alluxio.AlluxioURI)29 LockedInodePath (alluxio.master.file.meta.LockedInodePath)21 Test (org.junit.Test)21 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)16 LockingScheme (alluxio.master.file.meta.LockingScheme)15 InvalidPathException (alluxio.exception.InvalidPathException)12 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)11 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)10 Inode (alluxio.master.file.meta.Inode)9 MountTable (alluxio.master.file.meta.MountTable)7 FileInfo (alluxio.wire.FileInfo)7 AlluxioException (alluxio.exception.AlluxioException)4 LockedInodePathList (alluxio.master.file.meta.LockedInodePathList)4 Mode (alluxio.security.authorization.Mode)4 UnderFileSystem (alluxio.underfs.UnderFileSystem)4 FileBlockInfo (alluxio.wire.FileBlockInfo)4 DescendantType (alluxio.file.options.DescendantType)3 FileSystemMasterCommonPOptions (alluxio.grpc.FileSystemMasterCommonPOptions)3