Search in sources :

Example 71 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class TransactionHandleRegistryTest method shouldProvideInterruptHandlerForSuspendedTransaction.

@Test
void shouldProvideInterruptHandlerForSuspendedTransaction() throws TransactionLifecycleException {
    // Given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    FakeClock clock = Clocks.fakeClock();
    var memoryPool = mock(MemoryPool.class);
    int timeoutLength = 123;
    TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, Duration.ofMillis(timeoutLength), logProvider, memoryPool);
    TransactionHandle handle = mock(TransactionHandle.class);
    // Suspended Tx in Registry
    long id = registry.begin(handle);
    registry.release(id, handle);
    // When
    registry.terminate(id);
    // Then
    verify(handle).terminate();
    verifyNoMoreInteractions(handle);
    var inOrder = inOrder(memoryPool);
    inOrder.verify(memoryPool).reserveHeap(TransactionHandleRegistry.ACTIVE_TRANSACTION_SHALLOW_SIZE);
    inOrder.verify(memoryPool).reserveHeap(TransactionHandleRegistry.SUSPENDED_TRANSACTION_SHALLOW_SIZE);
    inOrder.verify(memoryPool).releaseHeap(TransactionHandleRegistry.SUSPENDED_TRANSACTION_SHALLOW_SIZE);
    inOrder.verifyNoMoreInteractions();
}
Also used : FakeClock(org.neo4j.time.FakeClock) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 72 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class TransactionHandleRegistryTest method gettingInterruptHandlerForUnknownIdShouldThrowErrorInvalidTransactionId.

@Test
void gettingInterruptHandlerForUnknownIdShouldThrowErrorInvalidTransactionId() {
    // Given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    FakeClock clock = Clocks.fakeClock();
    var memoryPool = mock(MemoryPool.class);
    int timeoutLength = 123;
    TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, Duration.ofMillis(timeoutLength), logProvider, memoryPool);
    // When
    assertThrows(InvalidTransactionId.class, () -> registry.terminate(456));
    verifyNoMoreInteractions(memoryPool);
}
Also used : FakeClock(org.neo4j.time.FakeClock) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 73 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class TransactionHandleRegistryTest method acquiringATransactionThatHasAlreadyBeenAcquiredShouldThrowInvalidConcurrentTransactionAccess.

@Test
void acquiringATransactionThatHasAlreadyBeenAcquiredShouldThrowInvalidConcurrentTransactionAccess() throws Exception {
    // Given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    var memoryPool = mock(MemoryPool.class);
    TransactionHandleRegistry registry = new TransactionHandleRegistry(Clocks.fakeClock(), Duration.ofMillis(0), logProvider, memoryPool);
    TransactionHandle handle = mock(TransactionHandle.class);
    long id = registry.begin(handle);
    registry.release(id, handle);
    registry.acquire(id);
    // When
    assertThrows(InvalidConcurrentTransactionAccess.class, () -> registry.acquire(id));
    // then
    assertThat(logProvider).doesNotHaveAnyLogs();
    var inOrder = inOrder(memoryPool);
    inOrder.verify(memoryPool).reserveHeap(TransactionHandleRegistry.ACTIVE_TRANSACTION_SHALLOW_SIZE);
    inOrder.verify(memoryPool).reserveHeap(TransactionHandleRegistry.SUSPENDED_TRANSACTION_SHALLOW_SIZE);
    inOrder.verify(memoryPool).releaseHeap(TransactionHandleRegistry.SUSPENDED_TRANSACTION_SHALLOW_SIZE);
    inOrder.verifyNoMoreInteractions();
}
Also used : AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 74 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class TransactionHandleRegistryTest method shouldProvideInterruptHandlerForActiveTransaction.

@Test
void shouldProvideInterruptHandlerForActiveTransaction() throws TransactionLifecycleException {
    // Given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    FakeClock clock = Clocks.fakeClock();
    var memoryPool = mock(MemoryPool.class);
    int timeoutLength = 123;
    TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, Duration.ofMillis(timeoutLength), logProvider, memoryPool);
    TransactionHandle handle = mock(TransactionHandle.class);
    // Active Tx in Registry
    long id = registry.begin(handle);
    // When
    registry.terminate(id);
    // Then
    verify(handle).terminate();
    verifyNoMoreInteractions(handle);
    verify(memoryPool).reserveHeap(TransactionHandleRegistry.ACTIVE_TRANSACTION_SHALLOW_SIZE);
    verify(memoryPool).releaseHeap(TransactionHandleRegistry.ACTIVE_TRANSACTION_SHALLOW_SIZE);
    verifyNoMoreInteractions(memoryPool);
}
Also used : FakeClock(org.neo4j.time.FakeClock) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 75 with AssertableLogProvider

use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.

the class DatabaseStartupTest method dumpSystemDiagnosticLoggingOnStartup.

@Test
void dumpSystemDiagnosticLoggingOnStartup() {
    AssertableLogProvider logProvider = new AssertableLogProvider();
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setInternalLogProvider(logProvider).setConfig(GraphDatabaseInternalSettings.dump_diagnostics, true).build();
    managementService.database(DEFAULT_DATABASE_NAME);
    try {
        assertThat(logProvider).containsMessages("System diagnostics", "System memory information", "JVM memory information", "Operating system information", "JVM information", "Java classpath", "Library path", "System properties", "(IANA) TimeZone database version", "Network information", "DBMS config");
    } finally {
        managementService.shutdown();
    }
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Aggregations

AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)202 Test (org.junit.jupiter.api.Test)98 Test (org.junit.Test)63 Path (java.nio.file.Path)29 Log (org.neo4j.logging.Log)24 FakeClock (org.neo4j.time.FakeClock)20 SslPolicyConfig (org.neo4j.configuration.ssl.SslPolicyConfig)14 IOException (java.io.IOException)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)12 SocketAddress (org.neo4j.configuration.helpers.SocketAddress)11 NullLog (org.neo4j.logging.NullLog)11 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)10 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ExecutingQuery (org.neo4j.kernel.api.query.ExecutingQuery)9 QueryLogger (org.neo4j.kernel.impl.query.QueryLoggerKernelExtension.QueryLogger)9 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)8 ServerSocket (java.net.ServerSocket)8 Before (org.junit.Before)8