Search in sources :

Example 6 with StoreUpgrader

use of org.neo4j.kernel.impl.storemigration.StoreUpgrader in project neo4j by neo4j.

the class StoreUpgraderTest method failMigrationWhenFailDuringTransactionInformationRetrieval.

@Test
public void failMigrationWhenFailDuringTransactionInformationRetrieval() throws IOException {
    File storeDirectory = directory.graphDbDir();
    File prepare = directory.directory("prepare");
    FileSystemAbstraction fs = new DelegatingFileSystemAbstraction(fileSystem) {

        @Override
        public File[] listFiles(File directory, FilenameFilter filter) {
            if (filter == LegacyLogFilenames.versionedLegacyLogFilesFilter) {
                sneakyThrow(new IOException("Enforced IO Exception Fail to open file"));
            }
            return super.listFiles(directory, filter);
        }
    };
    prepareSampleDatabase(version, fs, storeDirectory, prepare);
    // and a state of the migration saying that it has done the actual migration
    PageCache pageCache = pageCacheRule.getPageCache(fs);
    // remove metadata store record to force tx info lookup in tx logs
    MetaDataStore.setRecord(pageCache, new File(storeDirectory, MetaDataStore.DEFAULT_NAME), MetaDataStore.Position.LAST_TRANSACTION_COMMIT_TIMESTAMP, MetaDataRecordFormat.FIELD_NOT_PRESENT);
    UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), getRecordFormats()) {

        @Override
        public RecordFormats checkUpgradeable(File storeDirectory) {
            return getRecordFormats();
        }
    };
    SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
    StoreMigrator defaultMigrator = new StoreMigrator(fs, pageCache, getTuningConfig(), NullLogService.getInstance(), schemaIndexProvider);
    StoreUpgrader upgrader = new StoreUpgrader(upgradableDatabase, progressMonitor, allowMigrateConfig, fs, pageCache, NullLogProvider.getInstance());
    upgrader.addParticipant(defaultMigrator);
    expectedException.expect(UnableToUpgradeException.class);
    expectedException.expectCause(instanceOf(IOException.class));
    expectedException.expectCause(hasMessage(containsString("Enforced IO Exception Fail to open file")));
    upgrader.migrateIfNeeded(storeDirectory);
}
Also used : FilenameFilter(java.io.FilenameFilter) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) DelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.DelegatingFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) StoreMigrator(org.neo4j.kernel.impl.storemigration.participant.StoreMigrator) IOException(java.io.IOException) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) MigrationTestUtils.truncateFile(org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile) File(java.io.File) DelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.DelegatingFileSystemAbstraction) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Aggregations

StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)6 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)4 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)4 Test (org.junit.Test)3 PageCache (org.neo4j.io.pagecache.PageCache)3 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)3 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)3 File (java.io.File)2 IOException (java.io.IOException)2 Config (org.neo4j.kernel.configuration.Config)2 MigrationTestUtils.truncateFile (org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile)2 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)2 FilenameFilter (java.io.FilenameFilter)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 DelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.DelegatingFileSystemAbstraction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)1 StoreMigrationParticipant (org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant)1 UnableToUpgradeException (org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException)1 MigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.MigrationProgressMonitor)1