Search in sources :

Example 91 with AssertableLogProvider

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

the class NeoStoresDiagnosticsTest method setUp.

@BeforeEach
void setUp() {
    logProvider = new AssertableLogProvider();
    logger = logProvider.getLog(DiagnosticsManager.class);
}
Also used : DiagnosticsManager(org.neo4j.internal.diagnostics.DiagnosticsManager) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 92 with AssertableLogProvider

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

the class IndexIT method shouldBeAbleToRemoveAConstraintIndexWithoutOwner.

@Test
void shouldBeAbleToRemoveAConstraintIndexWithoutOwner() throws Exception {
    // given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, logProvider);
    IndexProviderDescriptor provider = GenericNativeIndexProvider.DESCRIPTOR;
    IndexPrototype prototype = uniqueForSchema(schema).withName("constraint name").withIndexProvider(provider);
    IndexDescriptor constraintIndex = creator.createConstraintIndex(prototype);
    // then
    KernelTransaction transaction = newTransaction();
    assertEquals(emptySet(), asSet(transaction.schemaRead().constraintsGetForLabel(labelId)));
    commit();
    // when
    SchemaWrite schemaWrite = schemaWriteInNewTransaction();
    schemaWrite.indexDrop(constraintIndex);
    commit();
    // then
    transaction = newTransaction();
    assertEquals(emptySet(), asSet(transaction.schemaRead().indexesGetForLabel(labelId)));
    commit();
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 93 with AssertableLogProvider

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

the class IndexPopulationJobTest method shouldLogJobProgress.

@Test
void shouldLogJobProgress() throws Exception {
    // Given
    createNode(map(name, "irrelephant"), FIRST);
    AssertableLogProvider logProvider = new AssertableLogProvider();
    FlippableIndexProxy index = mock(FlippableIndexProxy.class);
    when(index.getState()).thenReturn(InternalIndexState.ONLINE);
    IndexPopulator populator = indexPopulator(false);
    try {
        IndexPopulationJob job = newIndexPopulationJob(populator, index, indexStoreView, logProvider, EntityType.NODE, indexPrototype(FIRST, name, false));
        // When
        job.run();
        // Then
        var matcher = assertThat(logProvider).forClass(IndexPopulationJob.class).forLevel(INFO);
        matcher.containsMessageWithArgumentsContaining("Index population started: [%s]", "type='GENERAL BTREE', schema=(:FIRST {name})").containsMessages("TIME/PHASE Final: SCAN[");
    } finally {
        populator.close(true, CursorContext.NULL);
    }
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 94 with AssertableLogProvider

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

the class StoreAssertions method assertConsistentStore.

public static void assertConsistentStore(DatabaseLayout databaseLayout) throws ConsistencyCheckIncompleteException {
    Config configuration = Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m");
    AssertableLogProvider logger = new AssertableLogProvider();
    ConsistencyCheckService.Result result = new ConsistencyCheckService().runFullConsistencyCheck(databaseLayout, configuration, ProgressMonitorFactory.NONE, logger, false);
    assertTrue("Consistency check for " + databaseLayout + " found inconsistencies:\n\n" + logger.serialize(), result.isSuccessful());
}
Also used : Config(org.neo4j.configuration.Config) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider)

Example 95 with AssertableLogProvider

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

the class LoggingMonitorTest method shouldIncludeStackTraceWhenDebugLevel.

@Test
void shouldIncludeStackTraceWhenDebugLevel() {
    AssertableLogProvider logProvider = new AssertableLogProvider(true);
    LoggingMonitor monitor = new LoggingMonitor(logProvider.getLog(LoggingMonitorTest.class));
    IndexDescriptor index = forSchema(forLabel(1, 1)).withName("index").materialise(1);
    monitor.failedToOpenIndex(index, "I'll do something about this.", new Exception("Dammit Leroy!"));
    assertThat(logProvider).containsMessages("java.lang.Exception: Dammit Leroy!");
}
Also used : IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) 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