Search in sources :

Example 81 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource 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 82 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource 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 83 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource 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)

Example 84 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource 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 85 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource 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)

Aggregations

MethodSource (org.junit.jupiter.params.provider.MethodSource)1199 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1184 Transaction (org.neo4j.graphdb.Transaction)103 Stream (java.util.stream.Stream)70 Test (org.junit.jupiter.api.Test)67 ArrayList (java.util.ArrayList)63 InterruptAfter (io.aeron.test.InterruptAfter)60 List (java.util.List)60 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)58 TimeUnit (java.util.concurrent.TimeUnit)54 IOException (java.io.IOException)52 CountDownLatch (java.util.concurrent.CountDownLatch)52 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)52 lombok.val (lombok.val)52 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)51 Arguments (org.junit.jupiter.params.provider.Arguments)47 AfterEach (org.junit.jupiter.api.AfterEach)46 SSLEngine (javax.net.ssl.SSLEngine)44 AtomicReference (java.util.concurrent.atomic.AtomicReference)43 Path (java.nio.file.Path)42