Fix open telemetry container lifecycle issues

Mark test as `@DirtiesContext` so that the context is closed before
the container.

Closes gh-38176
This commit is contained in:
Phillip Webb
2023-11-01 18:16:38 -07:00
parent 9b71ef4114
commit 663243e60c

View File

@@ -40,6 +40,7 @@ import org.springframework.boot.testcontainers.service.connection.ServiceConnect
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
@@ -57,6 +58,7 @@ import static org.hamcrest.Matchers.matchesPattern;
@TestPropertySource(properties = { "management.otlp.metrics.export.resource-attributes.service.name=test",
"management.otlp.metrics.export.step=1s" })
@Testcontainers(disabledWithoutDocker = true)
@DirtiesContext
class OpenTelemetryMetricsContainerConnectionDetailsFactoryIntegrationTests {
private static final String OPENMETRICS_001 = "application/openmetrics-text; version=0.0.1; charset=utf-8";