Search in sources :

Example 16 with FsMasterResource

use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method addBlockTestUtil.

private void addBlockTestUtil(URIStatus status) 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(1, fsMaster.listStatus(mRootUri, ListStatusContext.mergeFrom(ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER))).size());
        long xyzId = fsMaster.getFileId(new AlluxioURI("/xyz"));
        Assert.assertTrue(xyzId != IdUtils.INVALID_FILE_ID);
        FileInfo fsMasterInfo = fsMaster.getFileInfo(xyzId);
        Assert.assertEquals(0, fsMaster.getFileInfo(xyzId).getInMemoryPercentage());
        Assert.assertEquals(status.getBlockIds(), fsMasterInfo.getBlockIds());
        Assert.assertEquals(status.getBlockSizeBytes(), fsMasterInfo.getBlockSizeBytes());
        Assert.assertEquals(status.getLength(), fsMasterInfo.getLength());
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI)

Example 17 with FsMasterResource

use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method fileTestUtil.

private void fileTestUtil(URIStatus status) 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(1, fsMaster.listStatus(mRootUri, ListStatusContext.mergeFrom(ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER))).size());
        long fileId = fsMaster.getFileId(new AlluxioURI("/xyz"));
        Assert.assertTrue(fileId != IdUtils.INVALID_FILE_ID);
        Assert.assertEquals(status, new URIStatus(fsMaster.getFileInfo(fileId).setMountId(status.getMountId())));
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 18 with FsMasterResource

use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method emptyFileSystem.

@Test
public void emptyFileSystem() throws Exception {
    Assert.assertEquals(0, mFileSystem.listStatus(mRootUri).size());
    mLocalAlluxioCluster.stopFS();
    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(0, fsMaster.listStatus(mRootUri, ListStatusContext.mergeFrom(ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER))).size());
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 19 with FsMasterResource

use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method manyFileTestUtil.

private void manyFileTestUtil() 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 k = 0; k < 10; 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 20 with FsMasterResource

use of alluxio.testutils.master.FsMasterResource in project alluxio by Alluxio.

the class UfsJournalIntegrationTest method renameTestUtil.

private void renameTestUtil() 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("/ii" + i + "/jj" + 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