use of org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant in project neo4j by neo4j.
the class StoreUpgraderTest method shouldContinueMovingFilesIfUpgradeCancelledWhileMoving.
@Test
public void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving() throws Exception {
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
String versionToMigrateTo = upgradableDatabase.currentVersion();
String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(dbDirectory).storeVersion();
// GIVEN
{
StoreUpgrader upgrader = newUpgrader(upgradableDatabase, allowMigrateConfig, pageCache);
String failureMessage = "Just failing";
upgrader.addParticipant(participantThatWillFailWhenMoving(failureMessage));
// WHEN
try {
upgrader.migrateIfNeeded(dbDirectory);
fail("should have thrown");
} catch (UnableToUpgradeException e) {
// THEN
assertTrue(e.getCause() instanceof IOException);
assertEquals(failureMessage, e.getCause().getMessage());
}
}
// AND WHEN
{
StoreUpgrader upgrader = newUpgrader(upgradableDatabase, pageCache);
StoreMigrationParticipant observingParticipant = Mockito.mock(StoreMigrationParticipant.class);
upgrader.addParticipant(observingParticipant);
upgrader.migrateIfNeeded(dbDirectory);
// THEN
verify(observingParticipant, Mockito.times(0)).migrate(any(File.class), any(File.class), any(MigrationProgressMonitor.Section.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
verify(observingParticipant, Mockito.times(1)).moveMigratedFiles(any(File.class), any(File.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
verify(observingParticipant, Mockito.times(1)).cleanup(any(File.class));
}
}
Aggregations