use of org.neo4j.kernel.impl.storemigration.UpgradableDatabase in project neo4j by neo4j.
the class StoreUpgraderTest method shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess.
@Test
public void shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess() throws IOException {
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
Config deniedMigrationConfig = Config.embeddedDefaults(MapUtil.stringMap(GraphDatabaseSettings.allow_store_upgrade.name(), "false"));
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
try {
newUpgrader(upgradableDatabase, deniedMigrationConfig, pageCache).migrateIfNeeded(dbDirectory);
fail("Should throw exception");
} catch (UpgradeNotAllowedByConfigurationException e) {
// expected
}
}
use of org.neo4j.kernel.impl.storemigration.UpgradableDatabase in project neo4j by neo4j.
the class StoreMigratorFrom20IT method setUp.
@Before
public void setUp() {
fs = fileSystemRule.get();
pageCache = pageCacheRule.getPageCache(fs);
File storeDirectory = storeDir.directory();
schemaIndexProvider = new LuceneSchemaIndexProvider(fs, DirectoryFactory.PERSISTENT, storeDirectory, NullLogProvider.getInstance(), Config.empty(), OperationalMode.single);
labelScanStoreProvider = NeoStoreDataSourceRule.nativeLabelScanStoreProvider(storeDirectory, fs, pageCache);
upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), recordFormat);
}
use of org.neo4j.kernel.impl.storemigration.UpgradableDatabase in project neo4j by neo4j.
the class StoreUpgraderTest method shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly.
@Test
public void shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly() throws IOException {
File comparisonDirectory = new File("target/" + StoreUpgraderTest.class.getSimpleName() + "shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly-comparison");
makeDbNotCleanlyShutdown(false);
fileSystem.deleteRecursively(comparisonDirectory);
fileSystem.copyRecursively(dbDirectory, comparisonDirectory);
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
try {
newUpgrader(upgradableDatabase, pageCache).migrateIfNeeded(dbDirectory);
fail("Should throw exception");
} catch (StoreUpgrader.UnableToUpgradeException e) {
// expected
}
verifyFilesHaveSameContent(fileSystem, comparisonDirectory, dbDirectory);
}
use of org.neo4j.kernel.impl.storemigration.UpgradableDatabase in project neo4j by neo4j.
the class StoreUpgraderTest method upgraderShouldCleanupLegacyLeftoverAndMigrationDirs.
@Test
public void upgraderShouldCleanupLegacyLeftoverAndMigrationDirs() throws Exception {
// Given
fileSystem.deleteFile(new File(dbDirectory, StoreLogService.INTERNAL_LOG_NAME));
fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_DIRECTORY));
fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY));
fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_1"));
fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_2"));
fileSystem.mkdir(new File(dbDirectory, StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_42"));
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
// When
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fileSystem, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fileSystem), getRecordFormats());
StoreUpgrader storeUpgrader = newUpgrader(upgradableDatabase, pageCache);
storeUpgrader.migrateIfNeeded(dbDirectory);
// Then
assertThat(migrationHelperDirs(), is(emptyCollectionOf(File.class)));
}
use of org.neo4j.kernel.impl.storemigration.UpgradableDatabase 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