From 449b87c9dcca69f14d9d355da9bc5bae66aeb588 Mon Sep 17 00:00:00 2001 From: Ales Justin Date: Tue, 21 Jan 2025 07:10:45 +0100 Subject: [PATCH] Fix wait strategy usage, Grafana should not know about LGTM --- .../testcontainers/GrafanaContainer.java | 20 ++++++------------- .../testcontainers/LgtmContainer.java | 13 ++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/GrafanaContainer.java b/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/GrafanaContainer.java index e7b101500af87..aced0b756ca19 100644 --- a/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/GrafanaContainer.java +++ b/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/GrafanaContainer.java @@ -1,7 +1,6 @@ package io.quarkus.observability.testcontainers; import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.containers.wait.strategy.WaitAllStrategy; import org.testcontainers.containers.wait.strategy.WaitStrategy; import io.quarkus.observability.common.config.GrafanaConfig; @@ -9,7 +8,6 @@ @SuppressWarnings("resource") public abstract class GrafanaContainer, C extends GrafanaConfig> extends ObservabilityContainer { - protected static final String DATASOURCES_PATH = "/etc/grafana/provisioning/datasources/custom.yaml"; protected C config; @@ -19,23 +17,17 @@ public GrafanaContainer(C config) { withEnv("GF_SECURITY_ADMIN_USER", config.username()); withEnv("GF_SECURITY_ADMIN_PASSWORD", config.password()); addExposedPort(config.grafanaPort()); - waitingFor(grafanaWaitStrategy()); + waitingFor(waitStrategy()); } public int getGrafanaPort() { return getMappedPort(config.grafanaPort()); } - private WaitStrategy grafanaWaitStrategy() { - return new WaitAllStrategy() - .withStartupTimeout(config.timeout()) - .withStrategy( - Wait.forHttp("/") - .forPort(config.grafanaPort()) - .forStatusCode(200) - .withStartupTimeout(config.timeout())) - .withStrategy( - Wait.forLogMessage(".*The OpenTelemetry collector and the Grafana LGTM stack are up and running.*", 1) - .withStartupTimeout(config.timeout())); + protected WaitStrategy waitStrategy() { + return Wait.forHttp("/") + .forPort(config.grafanaPort()) + .forStatusCode(200) + .withStartupTimeout(config.timeout()); } } diff --git a/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/LgtmContainer.java b/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/LgtmContainer.java index 6541307bc292e..bbf77c722d08a 100644 --- a/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/LgtmContainer.java +++ b/extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/LgtmContainer.java @@ -7,6 +7,9 @@ import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; import org.testcontainers.containers.output.OutputFrame; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.containers.wait.strategy.WaitAllStrategy; +import org.testcontainers.containers.wait.strategy.WaitStrategy; import org.testcontainers.utility.MountableFile; import io.quarkus.observability.common.ContainerConstants; @@ -92,6 +95,16 @@ public LgtmContainer(LgtmConfig config) { } + @Override + protected WaitStrategy waitStrategy() { + return new WaitAllStrategy() + .withStartupTimeout(config.timeout()) + .withStrategy(super.waitStrategy()) + .withStrategy( + Wait.forLogMessage(".*The OpenTelemetry collector and the Grafana LGTM stack are up and running.*", 1) + .withStartupTimeout(config.timeout())); + } + @Override protected String prefix() { return "LGTM";