Search in sources :

Example 1 with UnderFileSystemSpy

use of alluxio.UnderFileSystemSpy 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 2 with UnderFileSystemSpy

use of alluxio.UnderFileSystemSpy 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 3 with UnderFileSystemSpy

use of alluxio.UnderFileSystemSpy in project alluxio by Alluxio.

the class JournalIntegrationTest method failWhileDeletingCompletedLogs.

@Test
public void failWhileDeletingCompletedLogs() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    mFileSystem.createFile(file).close();
    AlluxioURI journal = new AlluxioURI(Configuration.get(PropertyKey.MASTER_JOURNAL_FOLDER));
    try (UnderFileSystemSpy ufsSpy = new UnderFileSystemSpy(journal)) {
        doThrow(new RuntimeException("Failed to delete completed log")).when(ufsSpy.get()).deleteFile(Mockito.contains("FileSystemMaster/completed"));
        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 completed log", 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)

Aggregations

AlluxioURI (alluxio.AlluxioURI)3 UnderFileSystemSpy (alluxio.UnderFileSystemSpy)3 FileSystemMaster (alluxio.master.file.FileSystemMaster)3 Test (org.junit.Test)3