Search in sources :

Example 1 with TransactionCounters

use of org.neo4j.kernel.impl.transaction.stats.TransactionCounters 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 2 with TransactionCounters

use of org.neo4j.kernel.impl.transaction.stats.TransactionCounters in project neo4j by neo4j.

the class TransactionMonitorTest method shouldCountRolledBackTransactions.

@ParameterizedTest(name = "{0}")
@MethodSource("parameters")
void shouldCountRolledBackTransactions(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.rollback();
        }
        checker.verifyRolledBacked(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 3 with TransactionCounters

use of org.neo4j.kernel.impl.transaction.stats.TransactionCounters in project neo4j by neo4j.

the class TransactionMonitorTest method shouldCountCommittedTransactions.

@ParameterizedTest(name = "{0}")
@MethodSource("parameters")
void shouldCountCommittedTransactions(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.commit();
        }
        checker.verifyCommitted(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)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)3 Transaction (org.neo4j.graphdb.Transaction)3 TransactionCounters (org.neo4j.kernel.impl.transaction.stats.TransactionCounters)3 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)3 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)3