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);
}
}
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);
}
}
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);
}
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);
}
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());
}
Aggregations