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));
}
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));
}
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));
}
Aggregations