Search in sources :

Example 56 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class FileSystemMasterRestartIntegrationTest method updateAccessTimeAsyncFlush.

/**
 * Tests journal is updated with access time asynchronously before master is stopped.
 */
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.MASTER_METASTORE, "HEAP" })
public void updateAccessTimeAsyncFlush() throws Exception {
    String parentName = "d1";
    AlluxioURI parentPath = new AlluxioURI("/" + parentName);
    long parentId = mFsMaster.createDirectory(parentPath, CreateDirectoryContext.mergeFrom(CreateDirectoryPOptions.newBuilder().setRecursive(true).setMode(new Mode((short) 0700).toProto())));
    long oldAccessTime = mFsMaster.getFileInfo(parentId).getLastAccessTimeMs();
    Thread.sleep(100);
    mFsMaster.listStatus(parentPath, ListStatusContext.defaults());
    long newAccessTime = mFsMaster.getFileInfo(parentId).getLastAccessTimeMs();
    // time is changed in master
    Assert.assertNotEquals(newAccessTime, oldAccessTime);
    try (FsMasterResource masterResource = createFileSystemMasterFromJournal()) {
        FileSystemMaster fsm = masterResource.getRegistry().get(FileSystemMaster.class);
        long journaledAccessTime = fsm.getFileInfo(parentId).getLastAccessTimeMs();
        // time is not flushed to journal
        Assert.assertEquals(journaledAccessTime, oldAccessTime);
    }
    // Stop Alluxio.
    mLocalAlluxioClusterResource.get().stopFS();
    // Create the master using the existing journal.
    try (FsMasterResource masterResource = createFileSystemMasterFromJournal()) {
        FileSystemMaster fsm = masterResource.getRegistry().get(FileSystemMaster.class);
        long journaledAccessTimeAfterStop = fsm.getFileInfo(parentId).getLastAccessTimeMs();
        // time is now flushed to journal
        Assert.assertEquals(journaledAccessTimeAfterStop, newAccessTime);
    }
}
Also used : Mode(alluxio.security.authorization.Mode) UfsMode(alluxio.underfs.UfsMode) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 57 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class FileSystemMasterRestartIntegrationTest method updateAccessTimeAsyncFlushAfterDelete.

/**
 * Tests journal is not updated with access time asynchronously after delete.
 */
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.MASTER_METASTORE, "HEAP" })
public void updateAccessTimeAsyncFlushAfterDelete() throws Exception {
    String parentName = "d1";
    AlluxioURI parentPath = new AlluxioURI("/" + parentName);
    long parentId = mFsMaster.createDirectory(parentPath, CreateDirectoryContext.mergeFrom(CreateDirectoryPOptions.newBuilder().setRecursive(true).setMode(new Mode((short) 0700).toProto())));
    long oldAccessTime = mFsMaster.getFileInfo(parentId).getLastAccessTimeMs();
    Thread.sleep(100);
    mFsMaster.listStatus(parentPath, ListStatusContext.defaults());
    long newAccessTime = mFsMaster.getFileInfo(parentId).getLastAccessTimeMs();
    // time is changed in master
    Assert.assertNotEquals(newAccessTime, oldAccessTime);
    try (FsMasterResource masterResource = createFileSystemMasterFromJournal()) {
        FileSystemMaster fsm = masterResource.getRegistry().get(FileSystemMaster.class);
        long journaledAccessTime = fsm.getFileInfo(parentId).getLastAccessTimeMs();
        // time is not flushed to journal
        Assert.assertEquals(journaledAccessTime, oldAccessTime);
        // delete the directory
        mFsMaster.delete(parentPath, DeleteContext.defaults());
    }
    // Stop Alluxio.
    mLocalAlluxioClusterResource.get().stopFS();
    // Create the master using the existing journal.
    try (FsMasterResource masterResource = createFileSystemMasterFromJournal()) {
        FileSystemMaster fsm = masterResource.getRegistry().get(FileSystemMaster.class);
        Assert.assertEquals(fsm.getFileId(parentPath), -1);
    }
}
Also used : Mode(alluxio.security.authorization.Mode) UfsMode(alluxio.underfs.UfsMode) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 58 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class ImpersonationIntegrationTest method before.

@Before
public void before() throws Exception {
    // Give the root dir 777, to write files as different users. This must be run as the user
    // that starts the master process
    FileSystem.Factory.create(ServerConfiguration.global()).setAttribute(new AlluxioURI("/"), SetAttributePOptions.newBuilder().setMode(new Mode((short) 0777).toProto()).build());
    // Enable client impersonation by default
    ServerConfiguration.set(PropertyKey.SECURITY_LOGIN_IMPERSONATION_USERNAME, Constants.IMPERSONATION_HDFS_USER);
}
Also used : Mode(alluxio.security.authorization.Mode) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Example 59 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class UfsSyncIntegrationTest method alluxioModeFingerprintUpdate.

@Test
public void alluxioModeFingerprintUpdate() throws Exception {
    GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.ONCE).setCommonOptions(PSYNC_NEVER).build();
    writeUfsFile(ufsPath(EXISTING_FILE), 10);
    Assert.assertNotNull(mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options));
    // Set initial alluxio permissions
    mFileSystem.setAttribute(new AlluxioURI(alluxioPath(EXISTING_FILE)), SetAttributePOptions.newBuilder().setMode(new Mode((short) 0777).toProto()).build());
    URIStatus status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
    String startFingerprint = status.getUfsFingerprint();
    // Change alluxio permissions
    mFileSystem.setAttribute(new AlluxioURI(alluxioPath(EXISTING_FILE)), SetAttributePOptions.newBuilder().setMode(new Mode((short) 0655).toProto()).build());
    status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
    String endFingerprint = status.getUfsFingerprint();
    // Verify the fingerprints are different.
    Assert.assertNotEquals(startFingerprint, endFingerprint);
}
Also used : Mode(alluxio.security.authorization.Mode) URIStatus(alluxio.client.file.URIStatus) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 60 with Mode

use of alluxio.security.authorization.Mode in project alluxio by Alluxio.

the class FileSystemMasterIntegrationTest method createDirectoryInNestedDirectories.

/**
 * Tests creating a directory in a nested directory load the UFS status of Inodes on the path.
 */
@Test
public void createDirectoryInNestedDirectories() throws Exception {
    String ufs = ServerConfiguration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS);
    String targetPath = Paths.get(ufs, "d1", "d2", "d3").toString();
    FileUtils.createDir(targetPath);
    FileUtils.changeLocalFilePermission(targetPath, new Mode((short) 0755).toString());
    String parentPath = Paths.get(ufs, "d1").toString();
    FileUtils.changeLocalFilePermission(parentPath, new Mode((short) 0700).toString());
    AlluxioURI path = new AlluxioURI(Paths.get("/d1", "d2", "d3", "d4").toString());
    mFsMaster.createDirectory(path, CreateDirectoryContext.mergeFrom(CreateDirectoryPOptions.newBuilder().setRecursive(true).setMode(new Mode((short) 0755).toProto())).setWriteType(WriteType.CACHE_THROUGH));
    long fileId = mFsMaster.getFileId(new AlluxioURI("/d1"));
    FileInfo fileInfo = mFsMaster.getFileInfo(fileId);
    Assert.assertEquals("d1", fileInfo.getName());
    Assert.assertTrue(fileInfo.isFolder());
    Assert.assertTrue(fileInfo.isPersisted());
    Assert.assertEquals(0700, (short) fileInfo.getMode());
}
Also used : FileInfo(alluxio.wire.FileInfo) Mode(alluxio.security.authorization.Mode) UfsMode(alluxio.underfs.UfsMode) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

Mode (alluxio.security.authorization.Mode)78 Test (org.junit.Test)47 AlluxioURI (alluxio.AlluxioURI)43 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)15 UnderFileSystem (alluxio.underfs.UnderFileSystem)14 Random (java.util.Random)14 IOException (java.io.IOException)11 UfsMode (alluxio.underfs.UfsMode)9 URIStatus (alluxio.client.file.URIStatus)8 FileInfo (alluxio.wire.FileInfo)8 ArrayList (java.util.ArrayList)8 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)7 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 WriteType (alluxio.client.WriteType)5 AlluxioException (alluxio.exception.AlluxioException)5 LockedInodePath (alluxio.master.file.meta.LockedInodePath)5 AclEntry (alluxio.security.authorization.AclEntry)5 AuthenticatedClientUserResource (alluxio.AuthenticatedClientUserResource)4 AuthenticatedUserRule (alluxio.AuthenticatedUserRule)4