From 893e2f906d906d763222a2fbf6e751a9c48dbffc Mon Sep 17 00:00:00 2001 From: Tomasz Kowalczewski Date: Fri, 19 Jul 2024 22:13:27 +0200 Subject: [PATCH] #123: Using Loki 3.1.0 for integration tests. (#125) --- .../tjahzi/LoggingSystemSanityCheckTest.java | 2 +- .../pl/tkowalcz/tjahzi/LoggingSystemTest.java | 2 +- core/src/test/resources/loki-config.yaml | 40 ++++++------------ .../log4j2/ServerNameIndicatorTest.java | 4 +- .../tjahzi/log4j2/infra/IntegrationTest.java | 2 +- .../labels/LabelsContextSubstitutionTest.java | 8 ++-- .../labels/Log4jPatternsInLabelsTest.java | 2 +- ...der-test-custom-endpoint-configuration.xml | 1 - .../src/test/resources/loki-config.yaml | 41 ++++++------------- .../tjahzi/logback/infra/IntegrationTest.java | 2 +- .../src/test/resources/loki-config.yaml | 41 ++++++------------- 11 files changed, 50 insertions(+), 95 deletions(-) diff --git a/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemSanityCheckTest.java b/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemSanityCheckTest.java index 86fc2a5..33d836d 100644 --- a/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemSanityCheckTest.java +++ b/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemSanityCheckTest.java @@ -30,7 +30,7 @@ class LoggingSystemSanityCheckTest { @Container - public GenericContainer loki = new GenericContainer("grafana/loki:2.3.0") + public GenericContainer loki = new GenericContainer("grafana/loki:3.1.0") .withCommand("-config.file=/etc/loki-config.yaml") .withClasspathResourceMapping("loki-config.yaml", "/etc/loki-config.yaml", diff --git a/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemTest.java b/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemTest.java index 7307ac0..72413ea 100644 --- a/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemTest.java +++ b/core/src/test/java/pl/tkowalcz/tjahzi/LoggingSystemTest.java @@ -33,7 +33,7 @@ class LoggingSystemTest { @Container - public GenericContainer loki = new GenericContainer("grafana/loki:2.3.0") + public GenericContainer loki = new GenericContainer("grafana/loki:3.1.0") .withCommand("-config.file=/etc/loki-config.yaml") .withClasspathResourceMapping("loki-config.yaml", "/etc/loki-config.yaml", diff --git a/core/src/test/resources/loki-config.yaml b/core/src/test/resources/loki-config.yaml index 47399f7..d58ca60 100644 --- a/core/src/test/resources/loki-config.yaml +++ b/core/src/test/resources/loki-config.yaml @@ -4,41 +4,27 @@ server: http_listen_port: 3100 log_level: debug -ingester: - lifecycler: - address: 127.0.0.1 - ring: - kvstore: - store: inmemory - replication_factor: 1 - min_ready_duration: 0s - final_sleep: 0s - chunk_idle_period: 5m - chunk_retain_period: 30s - max_transfer_retries: 0 +common: + ring: + instance_addr: 127.0.0.1 + kvstore: + store: inmemory + replication_factor: 1 + path_prefix: /tmp/loki schema_config: configs: - - from: 2018-04-15 - store: boltdb + - from: 2020-05-15 + store: tsdb object_store: filesystem - schema: v11 + schema: v13 index: prefix: index_ - period: 168h + period: 24h storage_config: - boltdb: - directory: /loki/index - filesystem: - directory: /loki/chunks + directory: /tmp/loki/chunks limits_config: - enforce_metric_name: false - reject_old_samples: true - reject_old_samples_max_age: 168h - -table_manager: - retention_deletes_enabled: false - retention_period: 0s + allow_structured_metadata: false diff --git a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ServerNameIndicatorTest.java b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ServerNameIndicatorTest.java index 8f3f093..dd308a5 100644 --- a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ServerNameIndicatorTest.java +++ b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/ServerNameIndicatorTest.java @@ -31,7 +31,7 @@ public class ServerNameIndicatorTest { public static Network network = Network.newNetwork(); @Container - public GenericContainer loki1 = new GenericContainer("grafana/loki:2.3.0") + public GenericContainer loki1 = new GenericContainer("grafana/loki:3.1.0") .withNetwork(network) .withNetworkAliases("loki1") .withCommand("-config.file=/etc/loki-config.yaml") @@ -46,7 +46,7 @@ public class ServerNameIndicatorTest { .withExposedPorts(3100); @Container - public GenericContainer loki2 = new GenericContainer("grafana/loki:2.3.0") + public GenericContainer loki2 = new GenericContainer("grafana/loki:3.1.0") .withNetwork(network) .withNetworkAliases("loki2") .withCommand("-config.file=/etc/loki-config.yaml") diff --git a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/infra/IntegrationTest.java b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/infra/IntegrationTest.java index e6e1055..97c2ca0 100644 --- a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/infra/IntegrationTest.java +++ b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/infra/IntegrationTest.java @@ -21,7 +21,7 @@ public class IntegrationTest { public static Network network = Network.newNetwork(); @Container - public GenericContainer loki = new GenericContainer("grafana/loki:2.3.0") + public GenericContainer loki = new GenericContainer("grafana/loki:3.1.0") .withNetwork(network) .withNetworkAliases("loki") .withCommand("-config.file=/etc/loki-config.yaml") diff --git a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/LabelsContextSubstitutionTest.java b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/LabelsContextSubstitutionTest.java index d08ff1f..53d3f4e 100644 --- a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/LabelsContextSubstitutionTest.java +++ b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/LabelsContextSubstitutionTest.java @@ -7,7 +7,7 @@ import pl.tkowalcz.tjahzi.log4j2.infra.IntegrationTest; import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.core.Every.everyItem; import static pl.tkowalcz.tjahzi.log4j2.infra.LokiAssert.assertThat; @@ -38,9 +38,9 @@ void shouldSendData() { .returns(response -> response .body("data.result.size()", equalTo(3)) .body("data.result.stream.server", everyItem(equalTo("127.0.0.1"))) - .body("data.result.stream.object", contains("prefix_", "prefix_bus_ticket", "prefix_comb")) - .body("data.result.stream.owner", contains("_suffix", "wally_suffix", "jennifer_suffix")) - .body("data.result.stream.default_value_test", contains("use_this_if_missing", "use_this_if_missing", "use_this_if_missing")) + .body("data.result.stream.object", containsInAnyOrder("prefix_", "prefix_bus_ticket", "prefix_comb")) + .body("data.result.stream.owner", containsInAnyOrder("_suffix", "wally_suffix", "jennifer_suffix")) + .body("data.result.stream.default_value_test", containsInAnyOrder("use_this_if_missing", "use_this_if_missing", "use_this_if_missing")) .body("data.result.values", hasItems( hasItems(hasItems("LabelsContextSubstitutionTest - Test3")), diff --git a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/Log4jPatternsInLabelsTest.java b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/Log4jPatternsInLabelsTest.java index 44c0be4..2254791 100644 --- a/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/Log4jPatternsInLabelsTest.java +++ b/log4j2-appender/src/test/java/pl/tkowalcz/tjahzi/log4j2/labels/Log4jPatternsInLabelsTest.java @@ -35,7 +35,7 @@ void shouldSendData() { .body("data.result.stream.server", everyItem(equalTo("127.0.0.1"))) .body("data.result.stream.class_pattern", everyItem(equalTo("p.t.t.l.l.Log4jPatternsInLabelsTest"))) .body("data.result.stream.sequence_number", contains("2", "1")) - .body("data.result.stream.mdc_tid", contains("", "req-230rq9ubou")) + .body("data.result.stream.mdc_tid", contains(null, "req-230rq9ubou")) .body("data.result.values", hasItems( hasItems(hasItems("Log4jPatternsInLabelsTest - Test2")), diff --git a/log4j2-appender/src/test/resources/appender-test-custom-endpoint-configuration.xml b/log4j2-appender/src/test/resources/appender-test-custom-endpoint-configuration.xml index 0024917..57abdde 100644 --- a/log4j2-appender/src/test/resources/appender-test-custom-endpoint-configuration.xml +++ b/log4j2-appender/src/test/resources/appender-test-custom-endpoint-configuration.xml @@ -20,7 +20,6 @@ tjahzi tjahzi - [%t] %d{DEFAULT} %5p %c{1} - %m%n%exception{full} diff --git a/log4j2-appender/src/test/resources/loki-config.yaml b/log4j2-appender/src/test/resources/loki-config.yaml index bb01454..d58ca60 100644 --- a/log4j2-appender/src/test/resources/loki-config.yaml +++ b/log4j2-appender/src/test/resources/loki-config.yaml @@ -4,42 +4,27 @@ server: http_listen_port: 3100 log_level: debug -ingester: - lifecycler: - address: 127.0.0.1 - ring: - kvstore: - store: inmemory - replication_factor: 1 - min_ready_duration: 0s - final_sleep: 0s - chunk_idle_period: 5m - chunk_retain_period: 30s - max_transfer_retries: 0 +common: + ring: + instance_addr: 127.0.0.1 + kvstore: + store: inmemory + replication_factor: 1 + path_prefix: /tmp/loki schema_config: configs: - - from: 2018-04-15 - store: boltdb + - from: 2020-05-15 + store: tsdb object_store: filesystem - schema: v11 + schema: v13 index: prefix: index_ - period: 168h + period: 24h storage_config: - boltdb: - directory: /loki/index - filesystem: - directory: /loki/chunks + directory: /tmp/loki/chunks limits_config: - enforce_metric_name: false - reject_old_samples: true - reject_old_samples_max_age: 168h - max_entries_limit_per_query: 10000 - -table_manager: - retention_deletes_enabled: false - retention_period: 0s + allow_structured_metadata: false diff --git a/logback-appender/src/test/java/pl/tkowalcz/tjahzi/logback/infra/IntegrationTest.java b/logback-appender/src/test/java/pl/tkowalcz/tjahzi/logback/infra/IntegrationTest.java index eb90636..42d8731 100644 --- a/logback-appender/src/test/java/pl/tkowalcz/tjahzi/logback/infra/IntegrationTest.java +++ b/logback-appender/src/test/java/pl/tkowalcz/tjahzi/logback/infra/IntegrationTest.java @@ -23,7 +23,7 @@ public class IntegrationTest { public static Network network = Network.newNetwork(); @Container - public GenericContainer loki = new GenericContainer("grafana/loki:2.3.0") + public GenericContainer loki = new GenericContainer("grafana/loki:3.1.0") .withNetwork(network) .withNetworkAliases("loki") .withCommand("-config.file=/etc/loki-config.yaml") diff --git a/logback-appender/src/test/resources/loki-config.yaml b/logback-appender/src/test/resources/loki-config.yaml index bb01454..d58ca60 100644 --- a/logback-appender/src/test/resources/loki-config.yaml +++ b/logback-appender/src/test/resources/loki-config.yaml @@ -4,42 +4,27 @@ server: http_listen_port: 3100 log_level: debug -ingester: - lifecycler: - address: 127.0.0.1 - ring: - kvstore: - store: inmemory - replication_factor: 1 - min_ready_duration: 0s - final_sleep: 0s - chunk_idle_period: 5m - chunk_retain_period: 30s - max_transfer_retries: 0 +common: + ring: + instance_addr: 127.0.0.1 + kvstore: + store: inmemory + replication_factor: 1 + path_prefix: /tmp/loki schema_config: configs: - - from: 2018-04-15 - store: boltdb + - from: 2020-05-15 + store: tsdb object_store: filesystem - schema: v11 + schema: v13 index: prefix: index_ - period: 168h + period: 24h storage_config: - boltdb: - directory: /loki/index - filesystem: - directory: /loki/chunks + directory: /tmp/loki/chunks limits_config: - enforce_metric_name: false - reject_old_samples: true - reject_old_samples_max_age: 168h - max_entries_limit_per_query: 10000 - -table_manager: - retention_deletes_enabled: false - retention_period: 0s + allow_structured_metadata: false