Search in sources :

Example 11 with StoreVersionCheck

use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method upgraderShouldCleanupLegacyLeftoverAndMigrationDirs.

@ParameterizedTest
@MethodSource("versions")
void upgraderShouldCleanupLegacyLeftoverAndMigrationDirs(RecordFormats formats) throws Exception {
    init(formats);
    // Given
    fileSystem.deleteFile(databaseLayout.file(INTERNAL_LOG_FILE));
    fileSystem.mkdir(databaseLayout.file(StoreUpgrader.MIGRATION_DIRECTORY));
    fileSystem.mkdir(databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY));
    fileSystem.mkdir(databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_1"));
    fileSystem.mkdir(databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_2"));
    fileSystem.mkdir(databaseLayout.file(StoreUpgrader.MIGRATION_LEFT_OVERS_DIRECTORY + "_42"));
    // When
    StoreVersionCheck check = getVersionCheck(pageCache);
    StoreUpgrader storeUpgrader = newUpgrader(check, pageCache);
    storeUpgrader.migrateIfNeeded(databaseLayout, false);
    // Then
    assertThat(migrationHelperDirs()).isEmpty();
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with StoreVersionCheck

use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method upgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId.

@ParameterizedTest
@MethodSource("versions")
void upgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId(RecordFormats formats) throws Exception {
    init(formats);
    // Given
    fileSystem.deleteFile(databaseLayout.file(INTERNAL_LOG_FILE));
    StoreVersionCheck check = getVersionCheck(pageCache);
    // When
    newUpgrader(check, allowMigrateConfig, pageCache).migrateIfNeeded(databaseLayout, false);
    // Then
    verifyStoreUpgradedWithin(1, MINUTES);
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 13 with StoreVersionCheck

use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method shouldContinueMovingFilesIfUpgradeCancelledWhileMoving.

@ParameterizedTest
@MethodSource("versions")
void shouldContinueMovingFilesIfUpgradeCancelledWhileMoving(RecordFormats formats) throws Exception {
    init(formats);
    StoreVersionCheck check = getVersionCheck(pageCache);
    String versionToMigrateTo = check.configuredVersion();
    StoreVersionCheck.Result upgradeResult = check.checkUpgrade(check.configuredVersion(), CursorContext.NULL);
    assertTrue(upgradeResult.outcome.isSuccessful());
    String versionToMigrateFrom = upgradeResult.actualVersion;
    // GIVEN
    {
        StoreUpgrader upgrader = newUpgrader(check, allowMigrateConfig, pageCache);
        String failureMessage = "Just failing";
        upgrader.addParticipant(participantThatWillFailWhenMoving(failureMessage));
        // WHEN
        var e = assertThrows(UnableToUpgradeException.class, () -> upgrader.migrateIfNeeded(databaseLayout, false));
        assertTrue(e.getCause() instanceof IOException);
        assertEquals(failureMessage, e.getCause().getMessage());
    }
    // AND WHEN
    {
        StoreUpgrader upgrader = newUpgrader(check, pageCache);
        StoreMigrationParticipant observingParticipant = Mockito.mock(StoreMigrationParticipant.class);
        upgrader.addParticipant(observingParticipant);
        upgrader.migrateIfNeeded(databaseLayout, false);
        // THEN
        verify(observingParticipant, Mockito.never()).migrate(any(DatabaseLayout.class), any(DatabaseLayout.class), any(ProgressReporter.class), eq(versionToMigrateFrom), eq(versionToMigrateTo), eq(IndexImporterFactory.EMPTY));
        verify(observingParticipant).moveMigratedFiles(any(DatabaseLayout.class), any(DatabaseLayout.class), eq(versionToMigrateFrom), eq(versionToMigrateTo));
        verify(observingParticipant).cleanup(any(DatabaseLayout.class));
    }
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) UnableToUpgradeException(org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException) AbstractStoreMigrationParticipant(org.neo4j.storageengine.migration.AbstractStoreMigrationParticipant) StoreMigrationParticipant(org.neo4j.storageengine.migration.StoreMigrationParticipant) IOException(java.io.IOException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with StoreVersionCheck

use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess.

@ParameterizedTest
@MethodSource("versions")
void shouldHaltUpgradeIfUpgradeConfigurationVetoesTheProcess(RecordFormats formats) throws IOException {
    init(formats);
    Config deniedMigrationConfig = Config.newBuilder().set(GraphDatabaseSettings.allow_upgrade, false).set(GraphDatabaseSettings.record_format, Standard.LATEST_NAME).build();
    StoreVersionCheck check = getVersionCheck(pageCache);
    assertThrows(UpgradeNotAllowedException.class, () -> newUpgrader(check, deniedMigrationConfig, pageCache).migrateIfNeeded(databaseLayout, false));
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) Config(org.neo4j.configuration.Config) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 15 with StoreVersionCheck

use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.

the class StoreUpgraderTest method upgradeShouldNotLeaveLeftoverAndMigrationDirs.

@ParameterizedTest
@MethodSource("versions")
void upgradeShouldNotLeaveLeftoverAndMigrationDirs(RecordFormats formats) throws Exception {
    init(formats);
    // Given
    fileSystem.deleteFile(databaseLayout.file(INTERNAL_LOG_FILE));
    StoreVersionCheck check = getVersionCheck(pageCache);
    // When
    newUpgrader(check, allowMigrateConfig, pageCache).migrateIfNeeded(databaseLayout, false);
    // Then
    assertThat(migrationHelperDirs()).isEmpty();
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

StoreVersionCheck (org.neo4j.storageengine.api.StoreVersionCheck)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 MethodSource (org.junit.jupiter.params.provider.MethodSource)15 Path (java.nio.file.Path)7 Config (org.neo4j.configuration.Config)4 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)4 Test (org.junit.jupiter.api.Test)3 IOException (java.io.IOException)2 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)2 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)2 ScanOnOpenOverwritingIdGeneratorFactory (org.neo4j.internal.id.ScanOnOpenOverwritingIdGeneratorFactory)1 CursorContext (org.neo4j.io.pagecache.context.CursorContext)1 PageCursorTracer (org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer)1 IndexProviderMap (org.neo4j.kernel.impl.api.index.IndexProviderMap)1 NeoStores (org.neo4j.kernel.impl.store.NeoStores)1 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)1 UnableToUpgradeException (org.neo4j.kernel.impl.storemigration.StoreUpgrader.UnableToUpgradeException)1 Log (org.neo4j.logging.Log)1 LogProvider (org.neo4j.logging.LogProvider)1 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)1