4040import org .testcontainers .containers .GenericContainer ;
4141import org .testcontainers .containers .Network ;
4242import org .testcontainers .containers .output .Slf4jLogConsumer ;
43+ import org .testcontainers .containers .wait .strategy .Wait ;
44+ import org .testcontainers .images .PullPolicy ;
4345import org .testcontainers .shaded .com .fasterxml .jackson .core .JsonProcessingException ;
4446import org .testcontainers .shaded .com .fasterxml .jackson .databind .ObjectMapper ;
4547import org .testcontainers .utility .DockerImageName ;
4648import org .testcontainers .utility .MountableFile ;
4749
4850public abstract class AbstractSmokeTest {
4951 private static final Logger log = LoggerFactory .getLogger (OpenTelemetryStorage .class );
50- private static final String OTEL_COLLECTOR_IMAGE = "otel/opentelemetry-collector:latest " ;
52+ private static final String OTEL_COLLECTOR_IMAGE = "otel/opentelemetry-collector:0.21.0 " ;
5153 private static final String MOCK_BACKEND_IMAGE =
5254 "ghcr.io/open-telemetry/java-test-containers:smoke-fake-backend-20201128.1734635" ;
5355 private static final String NETWORK_ALIAS_OTEL_COLLECTOR = "collector" ;
54- private static final String NETWORK_ALIAS_OTEL_MOCK_STORAGE = "storage " ;
56+ private static final String NETWORK_ALIAS_OTEL_MOCK_STORAGE = "backend " ;
5557 private static final String OTEL_EXPORTER_ENDPOINT =
5658 String .format ("http://%s:9411/api/v2/spans" , NETWORK_ALIAS_OTEL_COLLECTOR );
5759
@@ -76,22 +78,24 @@ public abstract class AbstractSmokeTest {
7678 public static void beforeAll () {
7779 openTelemetryStorage =
7880 new OpenTelemetryStorage (MOCK_BACKEND_IMAGE )
81+ .withImagePullPolicy (PullPolicy .alwaysPull ())
82+ .withExposedPorts (8080 )
83+ .waitingFor (Wait .forHttp ("/health" ).forPort (8080 ))
7984 .withNetwork (network )
8085 .withNetworkAliases (NETWORK_ALIAS_OTEL_MOCK_STORAGE )
8186 .withLogConsumer (new Slf4jLogConsumer (log ));
8287 openTelemetryStorage .start ();
8388
8489 collector =
8590 new OpenTelemetryCollector (OTEL_COLLECTOR_IMAGE )
91+ .withImagePullPolicy (PullPolicy .alwaysPull ())
8692 .withNetwork (network )
8793 .withNetworkAliases (NETWORK_ALIAS_OTEL_COLLECTOR )
8894 .withLogConsumer (new Slf4jLogConsumer (log ))
8995 .dependsOn (openTelemetryStorage )
9096 .withCopyFileToContainer (
91- MountableFile .forClasspathResource ("/otelcol-config.yaml" ),
92- "/etc/otelcol-config.yaml" )
93- .withLogConsumer (new Slf4jLogConsumer (log ))
94- .withCommand ("--config /etc/otelcol-config.yaml" );
97+ MountableFile .forClasspathResource ("/otel.yaml" ), "/etc/otel.yaml" )
98+ .withCommand ("--config /etc/otel.yaml" );
9599 collector .start ();
96100 }
97101
0 commit comments