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();
}
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);
}
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));
}
}
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));
}
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();
}
Aggregations