Search in sources :

Example 11 with FsMasterResource

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

the class FileSystemMasterRestartIntegrationTest method ufsModeReplay.

@Test
public void ufsModeReplay() throws Exception {
    mFsMaster.updateUfsMode(new AlluxioURI(mFsMaster.getUfsAddress()), UfsMode.NO_ACCESS);
    // Stop Alluxio.
    mLocalAlluxioClusterResource.get().stopFS();
    // Create the master using the existing journal.
    try (FsMasterResource masterResource = createFileSystemMasterFromJournal()) {
        FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        AlluxioURI alluxioFile = new AlluxioURI("/in_alluxio");
        // Create file should throw an Exception even after restart
        mThrown.expect(AccessControlException.class);
        fsMaster.createFile(alluxioFile, CreateFileContext.defaults().setWriteType(WriteType.CACHE_THROUGH));
    }
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 12 with FsMasterResource

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

the class FileSystemMasterRestartIntegrationTest method syncDirReplay.

@Test
public void syncDirReplay() throws Exception {
    AlluxioURI dir = new AlluxioURI("/dir/");
    // Add ufs nested file.
    String ufs = ServerConfiguration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS);
    Files.createDirectory(Paths.get(ufs, "dir"));
    Files.createFile(Paths.get(ufs, "dir", "file"));
    File ufsDir = new File(Paths.get(ufs, "dir").toString());
    Assert.assertTrue(ufsDir.setReadable(true, false));
    Assert.assertTrue(ufsDir.setWritable(true, false));
    Assert.assertTrue(ufsDir.setExecutable(true, false));
    // List dir with syncing
    FileInfo info = mFsMaster.getFileInfo(dir, GetStatusContext.mergeFrom(GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(0).build())));
    Assert.assertNotNull(info);
    Assert.assertEquals("dir", info.getName());
    // Retrieve the mode
    int mode = info.getMode();
    // Update mode of the ufs dir
    Assert.assertTrue(ufsDir.setExecutable(false, false));
    // List dir with syncing, should update the mode
    info = mFsMaster.getFileInfo(dir, GetStatusContext.mergeFrom(GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(0).build())));
    Assert.assertNotNull(info);
    Assert.assertEquals("dir", info.getName());
    Assert.assertNotEquals(mode, info.getMode());
    // update the expected mode
    mode = info.getMode();
    // Stop Alluxio.
    mLocalAlluxioClusterResource.get().stopFS();
    // Create the master using the existing journal.
    try (FsMasterResource masterResource = createFileSystemMasterFromJournal()) {
        FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        // List what is in Alluxio, without syncing.
        info = fsMaster.getFileInfo(dir, GetStatusContext.mergeFrom(GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(-1).build())));
        Assert.assertNotNull(info);
        Assert.assertEquals("dir", info.getName());
        Assert.assertEquals(mode, info.getMode());
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 13 with FsMasterResource

use of alluxio.testutils.master.FsMasterResource 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 14 with FsMasterResource

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

the class FileSystemMasterIntegrationTest method concurrentCreateJournal.

// TODO(calvin): This test currently relies on the fact the HDFS client is a cached instance to
// avoid invalid lease exception. This should be fixed.
@Ignore
@Test
public void concurrentCreateJournal() throws Exception {
    // Makes sure the file id's are the same between a master info and the journal it creates
    for (int i = 0; i < 5; i++) {
        ConcurrentCreator concurrentCreator = new ConcurrentCreator(DEPTH, CONCURRENCY_DEPTH, ROOT_PATH);
        concurrentCreator.call();
        try (FsMasterResource masterResource = createFileSystemMasterFromJournal()) {
            FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
            for (FileInfo info : mFsMaster.listStatus(new AlluxioURI("/"), ListStatusContext.defaults())) {
                AlluxioURI path = new AlluxioURI(info.getPath());
                Assert.assertEquals(mFsMaster.getFileId(path), fsMaster.getFileId(path));
            }
        }
        before();
    }
}
Also used : FileInfo(alluxio.wire.FileInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) AlluxioURI(alluxio.AlluxioURI) Ignore(org.junit.Ignore) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 15 with FsMasterResource

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

the class MultiUfsMountIntegrationTest method mountAfterMasterRestart.

@Test
public void mountAfterMasterRestart() throws Exception {
    mLocalAlluxioCluster.stopFS();
    try (FsMasterResource masterResource = MasterTestUtils.createLeaderFileSystemMasterFromJournal()) {
        FileSystemMaster fsMaster = masterResource.getRegistry().get(FileSystemMaster.class);
        Map<String, MountPointInfo> mountTable = fsMaster.getMountPointInfoSummary();
        Assert.assertTrue(mountTable.containsKey(MOUNT_POINT1));
        Assert.assertTrue(mountTable.containsKey(MOUNT_POINT2));
        MountPointInfo mountPointInfo1 = mountTable.get(MOUNT_POINT1);
        MountPointInfo mountPointInfo2 = mountTable.get(MOUNT_POINT2);
        Assert.assertEquals(mUfsUri1, mountPointInfo1.getUfsUri());
        Assert.assertEquals(mUfsUri2, mountPointInfo2.getUfsUri());
        Assert.assertEquals(UFS_CONF1, mountPointInfo1.getProperties());
        Assert.assertEquals(UFS_CONF2, mountPointInfo2.getProperties());
    }
}
Also used : MountPointInfo(alluxio.wire.MountPointInfo) FileSystemMaster(alluxio.master.file.FileSystemMaster) FsMasterResource(alluxio.testutils.master.FsMasterResource) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

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