Browse Source

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.
pull/41443/head
Andy Wilkinson 2 years ago
parent
commit
d9cebc4b17
  1. 2
      spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BaggagePropagationIntegrationTests.java

2
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; @@ -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; @@ -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";

Loading…
Cancel
Save