Search in sources :

Example 56 with AssertableLogProvider

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

the class SettingMigratorsTest method testQueryLogMigration.

private static void testQueryLogMigration(Boolean oldValue, LogQueryLevel newValue) {
    var setting = GraphDatabaseSettings.log_queries;
    Config config = Config.newBuilder().setRaw(Map.of(setting.name(), oldValue.toString())).build();
    var logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertEquals(newValue, config.get(setting));
    String msg = "Use of deprecated setting value %s=%s. It is replaced by %s=%s";
    assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessageWithArguments(msg, setting.name(), oldValue.toString(), setting.name(), newValue.name());
}
Also used : SslPolicyConfig(org.neo4j.configuration.ssl.SslPolicyConfig) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider)

Example 57 with AssertableLogProvider

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

the class SettingMigratorsTest method transactionCypherMaxAllocationsConflict.

@Test
void transactionCypherMaxAllocationsConflict() throws IOException {
    Path confFile = testDirectory.createFile("test.conf");
    Files.write(confFile, List.of("cypher.query_max_allocations=6g", memory_transaction_max_size.name() + "=7g"));
    Config config = Config.newBuilder().fromFile(confFile).build();
    var logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessageWithArguments("The setting cypher.query_max_allocations is removed and replaced by %s. Since both are set, %s will take " + "precedence and the value of cypher.query_max_allocations, %s, will be ignored.", memory_transaction_max_size.name(), memory_transaction_max_size.name(), "6g");
    assertEquals(BYTES.parse("7g"), config.get(memory_transaction_max_size));
}
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 58 with AssertableLogProvider

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

the class SettingMigratorsTest method logFormatMigrator.

@Test
void logFormatMigrator() throws IOException {
    Path confFile = testDirectory.createFile("test.conf");
    Files.write(confFile, List.of("unsupported.dbms.logs.format=JSON_FORMAT"));
    Config config = Config.newBuilder().fromFile(confFile).build();
    AssertableLogProvider logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessages("Use of deprecated setting unsupported.dbms.logs.format");
    assertThat(config.get(GraphDatabaseSettings.store_internal_log_format)).isEqualTo(FormattedLogFormat.JSON);
    assertThat(config.get(GraphDatabaseSettings.store_user_log_format)).isEqualTo(FormattedLogFormat.JSON);
    assertThat(config.get(GraphDatabaseSettings.log_query_format)).isEqualTo(FormattedLogFormat.JSON);
    Files.write(confFile, List.of("unsupported.dbms.logs.format=FOO"));
    config = Config.newBuilder().fromFile(confFile).build();
    logProvider = new AssertableLogProvider();
    config.setLogger(logProvider.getLog(Config.class));
    assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessages("Unrecognized value for unsupported.dbms.logs.format. Was FOO");
}
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 59 with AssertableLogProvider

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

the class SettingMigratorsTest method testKillQueryVerbose.

@Test
void testKillQueryVerbose() throws IOException {
    Path confFile = testDirectory.createFile("test.conf");
    Files.write(confFile, List.of("dbms.procedures.kill_query_verbose=false"));
    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 dbms.procedures.kill_query_verbose is removed. It's no longer possible to disable verbose kill query logging.");
}
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 60 with AssertableLogProvider

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

the class SettingMigratorsTest method testDefaultSchemaProvider.

@Test
void testDefaultSchemaProvider() throws IOException {
    Map<String, String> migrationMap = Map.of("lucene-1.0", "lucene+native-3.0", "lucene+native-1.0", "lucene+native-3.0", "lucene+native-2.0", "native-btree-1.0", "native-btree-1.0", "native-btree-1.0");
    for (String oldSchemaProvider : migrationMap.keySet()) {
        Path confFile = testDirectory.createFile("test.conf");
        Files.write(confFile, List.of("dbms.index.default_schema_provider=" + oldSchemaProvider));
        Config config = Config.newBuilder().fromFile(confFile).build();
        var logProvider = new AssertableLogProvider();
        config.setLogger(logProvider.getLog(Config.class));
        String expectedWarning = "Use of deprecated setting dbms.index.default_schema_provider.";
        if (!"native-btree-1.0".equals(oldSchemaProvider)) {
            expectedWarning += " Value migrated from " + oldSchemaProvider + " to " + migrationMap.get(oldSchemaProvider) + ".";
        }
        assertThat(logProvider).forClass(Config.class).forLevel(WARN).containsMessages(expectedWarning);
    }
}
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