Search in sources :

Example 1 with StoreVersionCheck

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

the class StoreUpgraderTest method upgradeShouldGiveProgressMonitorProgressMessages.

@ParameterizedTest
@MethodSource("versions")
void upgradeShouldGiveProgressMonitorProgressMessages(RecordFormats formats) throws Exception {
    init(formats);
    // Given
    StoreVersionCheck check = getVersionCheck(pageCache);
    // When
    AssertableLogProvider logProvider = new AssertableLogProvider();
    newUpgrader(check, pageCache, allowMigrateConfig, new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(databaseLayout, false);
    // Then
    assertThat(logProvider).containsMessages("Store files", "Indexes", "Successfully finished");
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with StoreVersionCheck

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

the class StoreUpgraderTest method failToMoveTransactionLogsIfTheyAlreadyExist.

@ParameterizedTest
@MethodSource("versions")
void failToMoveTransactionLogsIfTheyAlreadyExist(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);
    Path databaseTransactionLogsHome = txRoot.resolve(migrationLayout.getDatabaseName());
    fileSystem.mkdir(databaseTransactionLogsHome);
    createDummyTxLogFiles(databaseTransactionLogsHome);
    assertThrows(StoreUpgrader.TransactionLogsRelocationException.class, () -> newUpgrader(check, pageCache, config, new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(migrationLayout, false));
}
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 3 with StoreVersionCheck

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

the class StoreUpgraderTest method shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly.

@ParameterizedTest
@MethodSource("versions")
void shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly(RecordFormats formats) throws IOException {
    init(formats);
    Path comparisonDirectory = testDirectory.directory("shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly-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 4 with StoreVersionCheck

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

the class StoreUpgraderTest method tracePageCacheAccessOnStoreUpgrade.

@ParameterizedTest
@MethodSource("versions")
void tracePageCacheAccessOnStoreUpgrade(RecordFormats formats) throws IOException {
    init(formats);
    fileSystem.deleteFile(databaseLayout.file(INTERNAL_LOG_FILE));
    StoreVersionCheck check = getVersionCheck(pageCache);
    var pageCacheTracer = new DefaultPageCacheTracer();
    newUpgrader(check, allowMigrateConfig, pageCache, pageCacheTracer).migrateIfNeeded(databaseLayout, false);
    assertThat(pageCacheTracer.hits()).isGreaterThan(0);
    assertThat(pageCacheTracer.pins()).isGreaterThan(0);
    assertThat(pageCacheTracer.unpins()).isGreaterThan(0);
    assertThat(pageCacheTracer.faults()).isGreaterThan(0);
    StoreFactory factory = new StoreFactory(databaseLayout, allowMigrateConfig, new ScanOnOpenOverwritingIdGeneratorFactory(fileSystem, databaseLayout.getDatabaseName()), pageCache, fileSystem, NullLogProvider.getInstance(), NULL, writable());
    try (NeoStores neoStores = factory.openAllNeoStores()) {
        assertThat(neoStores.getMetaDataStore().getUpgradeTransaction()).isEqualTo(neoStores.getMetaDataStore().getLastCommittedTransaction());
        assertThat(neoStores.getMetaDataStore().getUpgradeTime()).isPositive();
    }
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) ScanOnOpenOverwritingIdGeneratorFactory(org.neo4j.internal.id.ScanOnOpenOverwritingIdGeneratorFactory) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with StoreVersionCheck

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

the class StoreUpgraderTest method upgradeFailsIfMigrationIsNotAllowed.

@ParameterizedTest
@MethodSource("versions")
void upgradeFailsIfMigrationIsNotAllowed(RecordFormats formats) throws IOException {
    init(formats);
    StoreVersionCheck check = getVersionCheck(pageCache);
    AssertableLogProvider logProvider = new AssertableLogProvider();
    assertThrows(UpgradeNotAllowedException.class, () -> newUpgrader(check, pageCache, Config.defaults(), new VisibleMigrationProgressMonitor(logProvider.getLog("test"))).migrateIfNeeded(databaseLayout, false));
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) 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