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.
This commit is contained in:
Andy Wilkinson 2024-07-10 13:27:29 +01:00
parent 375b3b16a0
commit d9cebc4b17
1 changed files with 2 additions and 0 deletions

View File

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