Search in sources :

Example 6 with StoreVersionCheck

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));
}
Also used : Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 7 with StoreVersionCheck

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());
}
Also used : Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 8 with StoreVersionCheck

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);
}
Also used : Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) Test(org.junit.jupiter.api.Test)

Example 9 with StoreVersionCheck

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());
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory)

Example 10 with StoreVersionCheck

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

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