From d9cebc4b1784566dea72f35812da9d8f134056f8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 10 Jul 2024 13:27:29 +0100 Subject: [PATCH] Stop BaggagePropagationIntegrationTests from being flaky Depending on what tests had already run, Otel tests in BaggagePropagationIntegrationTests could fail due to missing baggage related entries in the MDC. The entries were missing if Otel's ContextStorageWrappers had been marked as initialized without an EventPublishingContextWrapper containing event publisher that will publish to Slf4JBaggageEventListener. ContextStorageWrappers uses a static so this commit avoids to problem by forking a new classpath in BaggagePropagationIntegrationTests. This ensures that any previous static state in ContextStorageWrappers has no effect upon BaggagePropagationIntegrationTests. --- .../tracing/BaggagePropagationIntegrationTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java index 50af8b2b0d7..c4b2e29de47 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java @@ -33,6 +33,7 @@ import org.slf4j.MDC; import org.springframework.boot.actuate.autoconfigure.opentelemetry.OpenTelemetryAutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.testsupport.classpath.ForkedClassPath; import org.springframework.context.ApplicationContext; import static org.assertj.core.api.Assertions.assertThat; @@ -44,6 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Marcin Grzejszczak * @author Moritz Halbritter */ +@ForkedClassPath class BaggagePropagationIntegrationTests { private static final String COUNTRY_CODE = "country-code";