use of org.neo4j.kernel.impl.storemigration.UpgradableDatabase in project neo4j by neo4j.
the class StoreMigratorIT method shouldComputeTheLastTxLogPositionCorrectly.
@Test
public void shouldComputeTheLastTxLogPositionCorrectly() throws Throwable {
// GIVEN a legacy database
File storeDirectory = directory.graphDbDir();
File prepare = directory.directory("prepare");
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
// and a state of the migration saying that it has done the actual migration
LogService logService = NullLogService.getInstance();
PageCache pageCache = pageCacheRule.getPageCache(fs);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
fs.mkdirs(migrationDir);
// WHEN migrating
migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
// THEN it should compute the correct last tx log position
assertEquals(expectedLogPosition, migrator.readLastTxLogPosition(migrationDir));
}
use of org.neo4j.kernel.impl.storemigration.UpgradableDatabase in project neo4j by neo4j.
the class StoreMigratorIT method shouldBeAbleToResumeMigrationOnRebuildingCounts.
@Test
public void shouldBeAbleToResumeMigrationOnRebuildingCounts() throws Exception {
// GIVEN a legacy database
File storeDirectory = directory.graphDbDir();
File prepare = directory.directory("prepare");
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
// and a state of the migration saying that it has done the actual migration
LogService logService = NullLogService.getInstance();
PageCache pageCache = pageCacheRule.getPageCache(fs);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
fs.mkdirs(migrationDir);
migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
migrator.moveMigratedFiles(migrationDir, storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
// WHEN simulating resuming the migration
progressMonitor = new SilentMigrationProgressMonitor();
migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
migrator.rebuildCounts(storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
// THEN starting the new store should be successful
StoreFactory storeFactory = new StoreFactory(storeDirectory, pageCache, fs, logService.getInternalLogProvider());
storeFactory.openAllNeoStores().close();
}
Aggregations