Search in sources :

Example 76 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class IndexTxStateLookupTest method lookupWithoutTransactionWithCacheEviction.

@ParameterizedTest(name = "store=<{0}> lookup=<{1}>")
@MethodSource("argumentsProvider")
public void lookupWithoutTransactionWithCacheEviction(Object store, Object lookup) {
    init(store, lookup);
    // when
    Node node;
    try (Transaction tx = db.beginTx()) {
        (node = tx.createNode(label("Node"))).setProperty("prop", this.store);
        tx.commit();
    }
    // then
    try (Transaction tx = db.beginTx()) {
        assertEquals(1, count(tx.findNodes(label("Node"), "prop", this.lookup)));
        tx.commit();
    }
    deleteNode(node);
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 77 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class UniqueIndexRecoveryTest method shouldRecoverWhenCommandsTemporarilyViolateConstraints.

@ParameterizedTest
@MethodSource("parameters")
void shouldRecoverWhenCommandsTemporarilyViolateConstraints(SchemaIndex schemaIndex) throws Exception {
    setupDatabase(schemaIndex);
    // GIVEN
    Node unLabeledNode = createUnLabeledNodeWithProperty();
    Node labeledNode = createLabeledNode();
    createUniqueConstraint();
    // snapshot
    rotateLogAndCheckPoint();
    setPropertyOnLabeledNode(labeledNode);
    deletePropertyOnLabeledNode(labeledNode);
    addLabelToUnLabeledNode(unLabeledNode);
    // persist - recovery will do everything since last log rotate
    flushAll();
    // WHEN recovery is triggered
    restart(snapshot(storeDir.absolutePath()), schemaIndex);
    // it should just not blow up!
    try (Transaction tx = db.beginTx()) {
        assertThat(tx.findNode(LABEL, PROPERTY_KEY, PROPERTY_VALUE)).isEqualTo(unLabeledNode);
        tx.commit();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 78 with MethodSource

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

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class TransactionMonitorTest method shouldCountTerminatedTransactions.

@ParameterizedTest(name = "{0}")
@MethodSource("parameters")
void shouldCountTerminatedTransactions(String name, ThrowingConsumer<Transaction, Exception> txConsumer, boolean isWriteTx) throws Exception {
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder().impermanent().build();
    GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    try {
        TransactionCounters counts = db.getDependencyResolver().resolveDependency(TransactionCounters.class);
        TransactionCountersChecker checker = new TransactionCountersChecker(counts);
        try (Transaction tx = db.beginTx()) {
            txConsumer.accept(tx);
            tx.terminate();
        }
        checker.verifyTerminated(isWriteTx, counts);
    } finally {
        managementService.shutdown();
    }
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Transaction(org.neo4j.graphdb.Transaction) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionCounters(org.neo4j.kernel.impl.transaction.stats.TransactionCounters) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 80 with MethodSource

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

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