Search in sources :

Example 1 with FsMasterResource

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());
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 2 with FsMasterResource

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())));
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 3 with FsMasterResource

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);
        }
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI)

Example 4 with FsMasterResource

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());
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 5 with FsMasterResource

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);
            }
        }
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI)

Aggregations

FileSystemMaster (alluxio.master.file.FileSystemMaster)22 FsMasterResource (alluxio.testutils.master.FsMasterResource)22 AlluxioURI (alluxio.AlluxioURI)20 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)11 Test (org.junit.Test)11 FileInfo (alluxio.wire.FileInfo)8 URIStatus (alluxio.client.file.URIStatus)5 Mode (alluxio.security.authorization.Mode)2 UfsMode (alluxio.underfs.UfsMode)2 MountPointInfo (alluxio.wire.MountPointInfo)2 FileSystem (alluxio.client.file.FileSystem)1 AccessControlException (alluxio.exception.AccessControlException)1 MountPOptions (alluxio.grpc.MountPOptions)1 UfsDirectoryStatus (alluxio.underfs.UfsDirectoryStatus)1 UnderFileSystem (alluxio.underfs.UnderFileSystem)1 UnderFileSystemFactory (alluxio.underfs.UnderFileSystemFactory)1 File (java.io.File)1 IOException (java.io.IOException)1 Ignore (org.junit.Ignore)1 ExpectedException (org.junit.rules.ExpectedException)1