use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.
the class ClusterInitializationIntegrationTest method recoverClusterSuccess.
/**
* When a user starts a cluster with journal logs, which are generated by previous running
* cluster owned by the same user, it should succeed.
*/
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_LOGIN_USERNAME, SUPER_USER })
public void recoverClusterSuccess() throws Exception {
FileSystem fs = mLocalAlluxioClusterResource.get().getClient();
fs.createFile(new AlluxioURI("/testFile")).close();
mLocalAlluxioClusterResource.get().stopFS();
// user alluxio can recover master from journal
try (FsMasterResource masterResource = MasterTestUtils.createLeaderFileSystemMasterFromJournal()) {
FileSystemMaster fileSystemMaster = masterResource.getRegistry().get(FileSystemMaster.class);
AuthenticatedClientUser.set(SUPER_USER);
assertEquals(SUPER_USER, fileSystemMaster.getFileInfo(new AlluxioURI("/testFile"), GetStatusContext.defaults()).getOwner());
}
}
use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.
the class UfsJournalIntegrationTest method aclTestUtil.
private void aclTestUtil(URIStatus status, String user) throws Exception {
try (FsMasterResource masterResource = createFsMasterFromJournal()) {
FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
AuthenticatedClientUser.set(user);
FileInfo info = fsMaster.getFileInfo(new AlluxioURI("/file"), GetStatusContext.defaults());
Assert.assertEquals(status, new URIStatus(info.setMountId(status.getMountId())));
}
}
use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.
the class UfsJournalIntegrationTest method multiEditLogTestUtil.
private void multiEditLogTestUtil() throws Exception {
try (FsMasterResource masterResource = createFsMasterFromJournal()) {
FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
long rootId = fsMaster.getFileId(mRootUri);
Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
Assert.assertEquals(124, fsMaster.listStatus(mRootUri, ListStatusContext.mergeFrom(ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER))).size());
for (int k = 0; k < 124; k++) {
Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/a" + k)) != IdUtils.INVALID_FILE_ID);
}
}
}
use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.
the class UfsJournalIntegrationTest method pinTestUtil.
private void pinTestUtil(URIStatus directory, URIStatus file0, URIStatus file1) throws Exception {
try (FsMasterResource masterResource = createFsMasterFromJournal()) {
FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
FileInfo info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder")));
Assert.assertEquals(directory, new URIStatus(info.setMountId(directory.getMountId())));
Assert.assertTrue(info.isPinned());
info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder/file0")));
Assert.assertEquals(file0, new URIStatus(info.setMountId(file0.getMountId())));
Assert.assertFalse(info.isPinned());
info = fsMaster.getFileInfo(fsMaster.getFileId(new AlluxioURI("/myFolder/file1")));
Assert.assertEquals(file1, new URIStatus(info.setMountId(file1.getMountId())));
Assert.assertTrue(info.isPinned());
}
}
use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.
the class UfsJournalIntegrationTest method fileDirectoryTestUtil.
private void fileDirectoryTestUtil() throws Exception {
try (FsMasterResource masterResource = createFsMasterFromJournal()) {
FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
long rootId = fsMaster.getFileId(mRootUri);
Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
Assert.assertEquals(10, fsMaster.listStatus(mRootUri, ListStatusContext.mergeFrom(ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER))).size());
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/i" + i + "/j" + j)) != IdUtils.INVALID_FILE_ID);
}
}
}
}
Aggregations