Skip to content

Commit 5534ed1

Browse files
authored
Merge pull request #45734 from alesj/gwait1
Fix wait strategy usage, Grafana should not know about LGTM
2 parents f59ea88 + 449b87c commit 5534ed1

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package io.quarkus.observability.testcontainers;
22

33
import org.testcontainers.containers.wait.strategy.Wait;
4-
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
54
import org.testcontainers.containers.wait.strategy.WaitStrategy;
65

76
import io.quarkus.observability.common.config.GrafanaConfig;
87

98
@SuppressWarnings("resource")
109
public abstract class GrafanaContainer<T extends GrafanaContainer<T, C>, C extends GrafanaConfig>
1110
extends ObservabilityContainer<T, C> {
12-
protected static final String DATASOURCES_PATH = "/etc/grafana/provisioning/datasources/custom.yaml";
1311

1412
protected C config;
1513

@@ -19,23 +17,17 @@ public GrafanaContainer(C config) {
1917
withEnv("GF_SECURITY_ADMIN_USER", config.username());
2018
withEnv("GF_SECURITY_ADMIN_PASSWORD", config.password());
2119
addExposedPort(config.grafanaPort());
22-
waitingFor(grafanaWaitStrategy());
20+
waitingFor(waitStrategy());
2321
}
2422

2523
public int getGrafanaPort() {
2624
return getMappedPort(config.grafanaPort());
2725
}
2826

29-
private WaitStrategy grafanaWaitStrategy() {
30-
return new WaitAllStrategy()
31-
.withStartupTimeout(config.timeout())
32-
.withStrategy(
33-
Wait.forHttp("/")
34-
.forPort(config.grafanaPort())
35-
.forStatusCode(200)
36-
.withStartupTimeout(config.timeout()))
37-
.withStrategy(
38-
Wait.forLogMessage(".*The OpenTelemetry collector and the Grafana LGTM stack are up and running.*", 1)
39-
.withStartupTimeout(config.timeout()));
27+
protected WaitStrategy waitStrategy() {
28+
return Wait.forHttp("/")
29+
.forPort(config.grafanaPort())
30+
.forStatusCode(200)
31+
.withStartupTimeout(config.timeout());
4032
}
4133
}

extensions/observability-devservices/testcontainers/src/main/java/io/quarkus/observability/testcontainers/LgtmContainer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import org.eclipse.microprofile.config.Config;
88
import org.eclipse.microprofile.config.ConfigProvider;
99
import org.testcontainers.containers.output.OutputFrame;
10+
import org.testcontainers.containers.wait.strategy.Wait;
11+
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
12+
import org.testcontainers.containers.wait.strategy.WaitStrategy;
1013
import org.testcontainers.utility.MountableFile;
1114

1215
import io.quarkus.observability.common.ContainerConstants;
@@ -92,6 +95,16 @@ public LgtmContainer(LgtmConfig config) {
9295

9396
}
9497

98+
@Override
99+
protected WaitStrategy waitStrategy() {
100+
return new WaitAllStrategy()
101+
.withStartupTimeout(config.timeout())
102+
.withStrategy(super.waitStrategy())
103+
.withStrategy(
104+
Wait.forLogMessage(".*The OpenTelemetry collector and the Grafana LGTM stack are up and running.*", 1)
105+
.withStartupTimeout(config.timeout()));
106+
}
107+
95108
@Override
96109
protected String prefix() {
97110
return "LGTM";

0 commit comments

Comments
 (0)