Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wait strategy usage, Grafana should not know about LGTM #45734

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
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;

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

protected C config;

Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
Loading