use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method upgradeMoveTransactionLogs.
@ParameterizedTest
@MethodSource("versions")
void upgradeMoveTransactionLogs(RecordFormats formats) throws IOException {
init(formats);
Path txRoot = testDirectory.directory("customTxRoot");
AssertableLogProvider logProvider = new AssertableLogProvider();
StoreVersionCheck check = getVersionCheck(pageCache);
Config config = Config.newBuilder().fromConfig(allowMigrateConfig).set(neo4j_home, testDirectory.homePath()).set(GraphDatabaseSettings.transaction_logs_root_path, txRoot.toAbsolutePath()).set(default_database, databaseLayout.getDatabaseName()).build();
DatabaseLayout migrationLayout = DatabaseLayout.of(config);
newUpgrader(check, pageCache, config, new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(migrationLayout, false);
assertThat(logProvider).containsMessages("Starting transaction logs migration.", "Transaction logs migration completed.");
assertThat(getLogFiles(migrationLayout.databaseDirectory())).isEmpty();
Path databaseTransactionLogsHome = txRoot.resolve(migrationLayout.getDatabaseName());
assertTrue(fileSystem.fileExists(databaseTransactionLogsHome));
Set<String> logFileNames = getLogFileNames(databaseTransactionLogsHome);
assertThat(logFileNames).isNotEmpty();
assertThat(logFileNames).containsAll(getLogFileNames(prepareDatabaseDirectory));
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method shouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly.
@ParameterizedTest
@MethodSource("versions")
void shouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly(RecordFormats formats) throws IOException {
init(formats);
Path comparisonDirectory = testDirectory.directory("shouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly-comparison");
removeCheckPointFromTxLog(fileSystem, databaseLayout.databaseDirectory());
fileSystem.deleteRecursively(comparisonDirectory);
fileSystem.copyRecursively(databaseLayout.databaseDirectory(), comparisonDirectory);
StoreVersionCheck check = getVersionCheck(pageCache);
assertThrows(StoreUpgrader.UnableToUpgradeException.class, () -> newUpgrader(check, pageCache).migrateIfNeeded(databaseLayout, false));
verifyFilesHaveSameContent(fileSystem, comparisonDirectory, databaseLayout.databaseDirectory());
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class RecordStoreVersionCheckTest method shouldReportFileWithCorrectVersion.
@Test
void shouldReportFileWithCorrectVersion() throws IOException {
// given
Path neoStore = emptyFile(fileSystem);
String storeVersion = "V1";
long v1 = MetaDataStore.versionStringToLong(storeVersion);
MetaDataStore.setRecord(pageCache, neoStore, MetaDataStore.Position.STORE_VERSION, v1, databaseLayout.getDatabaseName(), NULL);
RecordStoreVersionCheck storeVersionCheck = newStoreVersionCheck();
// when
StoreVersionCheck.Result result = storeVersionCheck.checkUpgrade(storeVersion, NULL);
// then
assertTrue(result.outcome.isSuccessful());
assertEquals(Outcome.ok, result.outcome);
assertEquals(storeVersion, result.actualVersion);
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class StoreVersionLoader method loadStoreVersion.
/**
* Reads store version from the store files
* @param layout The la
* @return the {@link Result} of the store version if the format can not be read.
*/
public Result loadStoreVersion(DatabaseLayout layout) {
StorageEngineFactory sef = StorageEngineFactory.selectStorageEngine(fs, layout, pageCache).orElseGet(StorageEngineFactory::defaultStorageEngine);
StoreVersionCheck versionCheck = sef.versionCheck(fs, layout, config, pageCache, NullLogService.getInstance(), PageCacheTracer.NULL);
String storeVersion = versionCheck.storeVersion(CursorContext.NULL).orElseThrow(() -> new IllegalStateException("Can not read store version of database " + layout.getDatabaseName()));
return new Result(storeVersion, versionCheck.versionInformation(storeVersion).latest().storeVersion());
}
use of org.neo4j.storageengine.api.StoreVersionCheck in project neo4j by neo4j.
the class StoreUpgraderTest method shouldUpgradeIfUpgradeConfigurationVetoIsOverriddenByForce.
@ParameterizedTest
@MethodSource("versions")
void shouldUpgradeIfUpgradeConfigurationVetoIsOverriddenByForce(RecordFormats formats) throws IOException {
init(formats);
Config deniedMigrationConfig = Config.newBuilder().set(GraphDatabaseSettings.allow_upgrade, // Upgrade is not allowed.
false).set(GraphDatabaseSettings.record_format, Standard.LATEST_NAME).build();
StoreVersionCheck check = getVersionCheck(pageCache);
// Must not throw, because 'forceUpgrade' is 'true'.
newUpgrader(check, pageCache, deniedMigrationConfig, SILENT, NULL, true).migrateIfNeeded(databaseLayout, true);
verifyStoreUpgradedWithin(1, MINUTES);
}
Aggregations