use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck 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.StoreVersionCheck 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.StoreVersionCheck 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.StoreVersionCheck 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));
}
}
use of org.neo4j.kernel.impl.storemigration.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgradeOnStartupTest method setup.
@Before
public void setup() throws IOException {
fileSystem = fileSystemRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fileSystem);
workingDirectory = testDir.directory("working_" + version);
check = new StoreVersionCheck(pageCache);
File prepareDirectory = testDir.directory("prepare_" + version);
prepareSampleLegacyDatabase(version, fileSystem, workingDirectory, prepareDirectory);
assertEquals(!StandardV2_3.STORE_VERSION.equals(version), allLegacyStoreFilesHaveVersion(fileSystem, workingDirectory, version));
}
Aggregations