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();
}
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);
}
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();
}
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);
}
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();
}
}
Aggregations