Search in sources :

Example 51 with AssertableLogProvider

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

the class ConfigTest method shouldLogIfConfigFileCouldNotBeRead.

@Test
@DisabledForRoot
void shouldLogIfConfigFileCouldNotBeRead() throws IOException {
    AssertableLogProvider logProvider = new AssertableLogProvider(true);
    Log log = logProvider.getLog(Config.class);
    Path confFile = testDirectory.file("test.conf");
    assertTrue(confFile.toFile().createNewFile());
    assumeTrue(confFile.toFile().setReadable(false));
    Config config = Config.emptyBuilder().fromFileNoThrow(confFile).build();
    config.setLogger(log);
    assertThat(logProvider).containsMessages("Unable to load config file [%s]");
}
Also used : Path(java.nio.file.Path) Log(org.neo4j.logging.Log) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisabledForRoot(org.neo4j.test.extension.DisabledForRoot)

Example 52 with AssertableLogProvider

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

the class ConfigTest method testDoesNotLogChangedJvmArgs.

@Test
void testDoesNotLogChangedJvmArgs() throws IOException {
    Path confFile = testDirectory.createFile("test.conf");
    Files.write(confFile, List.of("dbms.jvm.additional=-XX:+UseG1GC", "dbms.jvm.additional=-XX:+AlwaysPreTouch", "dbms.jvm.additional=-XX:+UnlockExperimentalVMOptions", "dbms.jvm.additional=-XX:+TrustFinalNonStaticFields"));
    Config config = Config.newBuilder().fromFile(confFile).build();
    var logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertThat(logProvider).doesNotHaveAnyLogs();
}
Also used : Path(java.nio.file.Path) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 53 with AssertableLogProvider

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

the class ConfigTest method buildWithoutErrorsOrWarnings.

private static Config buildWithoutErrorsOrWarnings(Supplier<Config> buildConfig) {
    AssertableLogProvider lp = new AssertableLogProvider();
    Config config = buildConfig.get();
    // The config uses a buffering log, when you supply it with a log (i.e. our mock) it replays the buffered log into it
    config.setLogger(lp.getLog(Config.class));
    assertThat(lp).forLevel(AssertableLogProvider.Level.WARN).doesNotHaveAnyLogs();
    assertThat(lp).forLevel(AssertableLogProvider.Level.ERROR).doesNotHaveAnyLogs();
    return config;
}
Also used : AssertableLogProvider(org.neo4j.logging.AssertableLogProvider)

Example 54 with AssertableLogProvider

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

the class SettingMigratorsTest method testConsistencyCheckerFailFastRename.

@Test
void testConsistencyCheckerFailFastRename() throws IOException {
    Path confFile = testDirectory.createFile("test.conf");
    Files.write(confFile, List.of("unsupported.consistency_checker.experimental.fail_fast=1"));
    Config config = Config.newBuilder().fromFile(confFile).build();
    var logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessages("Use of deprecated setting unsupported.consistency_checker.experimental.fail_fast. " + "It is replaced by unsupported.consistency_checker.fail_fast_threshold");
    assertEquals(1, config.get(GraphDatabaseInternalSettings.consistency_checker_fail_fast_threshold));
}
Also used : Path(java.nio.file.Path) SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 55 with AssertableLogProvider

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

the class SettingMigratorsTest method testExperimentalConsistencyCheckerRemoval.

@Test
void testExperimentalConsistencyCheckerRemoval() throws IOException {
    Path confFile = testDirectory.createFile("test.conf");
    Files.write(confFile, List.of("unsupported.consistency_checker.experimental=true"));
    Config config = Config.newBuilder().fromFile(confFile).build();
    var logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessages("Setting unsupported.consistency_checker.experimental is removed. There is no longer multiple different consistency checkers to choose from.");
}
Also used : Path(java.nio.file.Path) SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

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