Search in sources :

Example 6 with UpgradableDatabase

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
    }
}
Also used : UpgradeNotAllowedByConfigurationException(org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) Config(org.neo4j.kernel.configuration.Config) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 7 with UpgradableDatabase

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);
}
Also used : LuceneSchemaIndexProvider(org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) File(java.io.File) Before(org.junit.Before)

Example 8 with UpgradableDatabase

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);
}
Also used : UnableToUpgradeException(org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) 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) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 9 with UpgradableDatabase

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)));
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) 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) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 10 with UpgradableDatabase

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));
    }
}
Also used : StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) UnableToUpgradeException(org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException) SilentMigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor) MigrationProgressMonitor(org.neo4j.kernel.impl.storemigration.monitoring.MigrationProgressMonitor) StoreMigrationParticipant(org.neo4j.kernel.impl.storemigration.StoreMigrationParticipant) AbstractStoreMigrationParticipant(org.neo4j.kernel.impl.storemigration.participant.AbstractStoreMigrationParticipant) UpgradableDatabase(org.neo4j.kernel.impl.storemigration.UpgradableDatabase) Matchers.containsString(org.hamcrest.Matchers.containsString) StoreUpgrader(org.neo4j.kernel.impl.storemigration.StoreUpgrader) IOException(java.io.IOException) LegacyStoreVersionCheck(org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Aggregations

StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)17 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)17 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)17 Test (org.junit.Test)16 PageCache (org.neo4j.io.pagecache.PageCache)16 File (java.io.File)14 SilentMigrationProgressMonitor (org.neo4j.kernel.impl.storemigration.monitoring.SilentMigrationProgressMonitor)8 MigrationTestUtils.truncateFile (org.neo4j.kernel.impl.storemigration.MigrationTestUtils.truncateFile)7 LogService (org.neo4j.kernel.impl.logging.LogService)6 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)6 StoreUpgrader (org.neo4j.kernel.impl.storemigration.StoreUpgrader)6 Matchers.containsString (org.hamcrest.Matchers.containsString)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 UnableToUpgradeException (org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException)3 StoreMigrator (org.neo4j.kernel.impl.storemigration.participant.StoreMigrator)3 IOException (java.io.IOException)2 FilenameFilter (java.io.FilenameFilter)1 Before (org.junit.Before)1 DelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.DelegatingFileSystemAbstraction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1