@Override public void migrate( DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo ) throws IOException { super.migrate( directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, versionToMigrateTo ); throw new RuntimeException( "This upgrade is failing" ); } };
@Test public void shouldNotMigrateFilesForVersionsWithSameCapability() throws Exception { // Prepare migrator and file StoreMigrator migrator = newStoreMigrator(); DatabaseLayout dbLayout = directory.databaseLayout(); File neoStore = dbLayout.metadataStore(); neoStore.createNewFile(); // Monitor what happens MyProgressReporter progressReporter = new MyProgressReporter(); // Migrate with two storeversions that have the same FORMAT capabilities migrator.migrate( dbLayout, directory.databaseLayout( "migrationDir" ), progressReporter, StandardV3_0.STORE_VERSION, StandardV3_2.STORE_VERSION ); // Should not have started any migration assertFalse( progressReporter.started ); }
@Test public void shouldComputeTheLastTxInfoCorrectly() throws Exception { // given DatabaseLayout databaseLayout = directory.databaseLayout(); File prepare = directory.directory( "prepare" ); MigrationTestUtils.prepareSampleLegacyDatabase( version, fs, databaseLayout.databaseDirectory(), prepare ); // and a state of the migration saying that it has done the actual migration LogService logService = NullLogService.getInstance(); PageCache pageCache = pageCacheRule.getPageCache( fs ); LogTailScanner tailScanner = getTailScanner( databaseLayout.databaseDirectory() ); UpgradableDatabase upgradableDatabase = getUpgradableDatabase( pageCache, tailScanner ); String versionToMigrateFrom = upgradableDatabase.checkUpgradable( databaseLayout ).storeVersion(); SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor(); StoreMigrator migrator = new StoreMigrator( fs, pageCache, CONFIG, logService, jobScheduler ); DatabaseLayout migrationLayout = directory.databaseLayout( StoreUpgrader.MIGRATION_DIRECTORY ); // when migrator.migrate( databaseLayout, migrationLayout, progressMonitor.startSection( "section" ), versionToMigrateFrom, upgradableDatabase.currentVersion() ); // then assertTrue( txIdComparator.apply( migrator.readLastTxInformation( migrationLayout ) ) ); }
@Test public void shouldComputeTheLastTxLogPositionCorrectly() throws Throwable { // GIVEN a legacy database DatabaseLayout databaseLayout = directory.databaseLayout(); File prepare = directory.directory( "prepare" ); MigrationTestUtils.prepareSampleLegacyDatabase( version, fs, databaseLayout.databaseDirectory(), prepare ); // and a state of the migration saying that it has done the actual migration LogService logService = NullLogService.getInstance(); PageCache pageCache = pageCacheRule.getPageCache( fs ); LogTailScanner tailScanner = getTailScanner( databaseLayout.databaseDirectory() ); UpgradableDatabase upgradableDatabase = getUpgradableDatabase( pageCache, tailScanner ); String versionToMigrateFrom = upgradableDatabase.checkUpgradable( databaseLayout ).storeVersion(); SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor(); StoreMigrator migrator = new StoreMigrator( fs, pageCache, CONFIG, logService, jobScheduler ); DatabaseLayout migrationLayout = directory.databaseLayout( StoreUpgrader.MIGRATION_DIRECTORY ); // WHEN migrating migrator.migrate( databaseLayout, migrationLayout, progressMonitor.startSection( "section" ), versionToMigrateFrom, upgradableDatabase.currentVersion() ); // THEN it should compute the correct last tx log position assertEquals( expectedLogPosition, migrator.readLastTxLogPosition( migrationLayout ) ); }
StoreMigrator migrator = new StoreMigrator( fs, pageCache, CONFIG, logService, jobScheduler ); DatabaseLayout migrationLayout = directory.databaseLayout( StoreUpgrader.MIGRATION_DIRECTORY ); migrator.migrate( databaseLayout, migrationLayout, progressMonitor.startSection( "section" ), versionToMigrateFrom, upgradableDatabase.currentVersion() );
migrator.migrate( databaseLayout, migrationLayout, progressMonitor.startSection( "section" ), versionToMigrateFrom, upgradableDatabase.currentVersion() ); countsMigrator
CountsMigrator countsMigrator = new CountsMigrator( fs, pageCache, CONFIG ); DatabaseLayout migrationLayout = directory.databaseLayout( StoreUpgrader.MIGRATION_DIRECTORY ); migrator.migrate( databaseLayout, migrationLayout, progressMonitor.startSection( "section" ), versionToMigrateFrom, upgradableDatabase.currentVersion() ); countsMigrator