Search in sources :

Example 21 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class JournalIntegrationTest method failDuringCheckpointRename.

@Test
public void failDuringCheckpointRename() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    mFileSystem.createFile(file).close();
    // Restart the master once so that it creates a checkpoint file.
    mLocalAlluxioCluster.stopFS();
    createFsMasterFromJournal();
    AlluxioURI journal = new AlluxioURI(Configuration.get(PropertyKey.MASTER_JOURNAL_FOLDER));
    try (UnderFileSystemSpy ufsSpy = new UnderFileSystemSpy(journal)) {
        doThrow(new RuntimeException("Failed to rename")).when(ufsSpy.get()).renameFile(Mockito.contains("FileSystemMaster/checkpoint.data.tmp"), anyString());
        try {
            // Restart the master again, but with renaming the checkpoint file failing.
            mLocalAlluxioCluster.stopFS();
            createFsMasterFromJournal();
            Assert.fail("Should have failed during rename");
        } catch (RuntimeException e) {
            Assert.assertEquals("Failed to rename", e.getMessage());
        }
    }
    // We shouldn't lose track of the fact that the file is loaded into memory.
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    Assert.assertTrue(fsMaster.getInMemoryFiles().contains(file));
}
Also used : UnderFileSystemSpy(alluxio.UnderFileSystemSpy) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 22 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class JournalIntegrationTest method rename.

/**
   * Tests file and directory creation, and rename.
   */
@Test
public void rename() throws Exception {
    for (int i = 0; i < 10; i++) {
        mFileSystem.createDirectory(new AlluxioURI("/i" + i));
        for (int j = 0; j < 10; j++) {
            CreateFileOptions option = CreateFileOptions.defaults().setBlockSizeBytes((i + j + 1) * 64);
            AlluxioURI path = new AlluxioURI("/i" + i + "/j" + j);
            mFileSystem.createFile(path, option).close();
            mFileSystem.rename(path, new AlluxioURI("/i" + i + "/jj" + j));
        }
        mFileSystem.rename(new AlluxioURI("/i" + i), new AlluxioURI("/ii" + i));
    }
    mLocalAlluxioCluster.stopFS();
    renameTestUtil();
    deleteFsMasterJournalLogs();
    renameTestUtil();
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 23 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class JournalIntegrationTest method failDuringCheckpointDelete.

@Test
public void failDuringCheckpointDelete() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    mFileSystem.createFile(file).close();
    // Restart the master once so that it creates a checkpoint file.
    mLocalAlluxioCluster.stopFS();
    createFsMasterFromJournal();
    AlluxioURI journal = new AlluxioURI(Configuration.get(PropertyKey.MASTER_JOURNAL_FOLDER));
    try (UnderFileSystemSpy ufsSpy = new UnderFileSystemSpy(journal)) {
        doThrow(new RuntimeException("Failed to delete")).when(ufsSpy.get()).deleteFile(Mockito.contains("FileSystemMaster/checkpoint.data"));
        try {
            // Restart the master again, but with deleting the checkpoint file failing.
            mLocalAlluxioCluster.stopFS();
            createFsMasterFromJournal();
            Assert.fail("Should have failed during delete");
        } catch (RuntimeException e) {
            Assert.assertEquals("Failed to delete", e.getMessage());
        }
    }
    // We shouldn't lose track of the fact that the file is loaded into memory.
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    Assert.assertTrue(fsMaster.getInMemoryFiles().contains(file));
}
Also used : UnderFileSystemSpy(alluxio.UnderFileSystemSpy) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 24 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class JournalIntegrationTest method manyFileTestUtil.

private void manyFileTestUtil() throws Exception {
    FileSystemMaster fsMaster = createFsMasterFromJournal();
    long rootId = fsMaster.getFileId(mRootUri);
    Assert.assertTrue(rootId != IdUtils.INVALID_FILE_ID);
    Assert.assertEquals(10, fsMaster.listStatus(mRootUri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Never)).size());
    for (int k = 0; k < 10; k++) {
        Assert.assertTrue(fsMaster.getFileId(new AlluxioURI("/a" + k)) != IdUtils.INVALID_FILE_ID);
    }
    fsMaster.stop();
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI)

Example 25 with AlluxioURI

use of alluxio.AlluxioURI in project alluxio by Alluxio.

the class JournalIntegrationTest method multiEditLog.

/**
   * Tests reading multiple edit logs.
   */
@Test
public void multiEditLog() throws Exception {
    for (int i = 0; i < 124; i++) {
        CreateFileOptions op = CreateFileOptions.defaults().setBlockSizeBytes((i + 10) / 10 * 64);
        mFileSystem.createFile(new AlluxioURI("/a" + i), op).close();
    }
    mLocalAlluxioCluster.stopFS();
    multiEditLogTestUtil();
    deleteFsMasterJournalLogs();
    multiEditLogTestUtil();
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1552 Test (org.junit.Test)1094 URIStatus (alluxio.client.file.URIStatus)356 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)303 IOException (java.io.IOException)154 FileInStream (alluxio.client.file.FileInStream)152 FileInfo (alluxio.wire.FileInfo)130 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)124 ArrayList (java.util.ArrayList)120 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)119 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)114 File (java.io.File)107 FileSystem (alluxio.client.file.FileSystem)99 FileOutStream (alluxio.client.file.FileOutStream)97 AlluxioException (alluxio.exception.AlluxioException)92 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)76 InvalidPathException (alluxio.exception.InvalidPathException)68 AbstractAlluxioShellTest (alluxio.shell.AbstractAlluxioShellTest)63 UnderFileSystem (alluxio.underfs.UnderFileSystem)63 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)62