From 79d2969930334e554cf081989f0cc2fc13b9d6e2 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 26 Feb 2021 09:58:16 +0100 Subject: [PATCH] Added debug info --- .../client/integration/WebClientTests.java | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java index 9f7e468b5..a044f57d5 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/integration/WebClientTests.java @@ -58,6 +58,7 @@ import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; import org.junit.runner.RunWith; import org.reactivestreams.Subscription; import reactor.core.publisher.BaseSubscriber; @@ -167,6 +168,11 @@ public class WebClientTests { this.testErrorController.clear(); this.fooController.clear(); } + + @Before + public void setup() { + log.info("Starting test"); + } @Test @Parameters @@ -191,6 +197,11 @@ public class WebClientTests { // at the interceptor level then(noTraceSpan.get().tags().get("http.url")).matches(".*/notrace"); }); + thenThereIsNoCurrentSpan(); + } + + private void thenThereIsNoCurrentSpan() { + log.info("Current span [" + this.tracer.currentSpan() + "]"); then(this.tracer.currentSpan()).isNull(); } @@ -241,7 +252,7 @@ public class WebClientTests { } then(this.spans).isEmpty(); - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); } Object[] parametersForShouldPropagateNotSamplingHeader() throws Exception { @@ -270,7 +281,7 @@ public class WebClientTests { span.finish(); } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.spans).isNotEmpty(); } @@ -288,7 +299,7 @@ public class WebClientTests { then(response).isNotEmpty(); } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.spans).isNotEmpty().extracting("traceId", String.class) .containsOnly(span.context().traceIdString()); then(this.spans).extracting("kind.name").contains("CLIENT"); @@ -327,7 +338,7 @@ public class WebClientTests { client.close(); } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.spans).isNotEmpty().extracting("traceId", String.class) .containsOnly(span.context().traceIdString()); then(this.spans).extracting("kind.name").contains("CLIENT"); @@ -345,7 +356,7 @@ public class WebClientTests { finally { span.finish(); } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.spans).isNotEmpty().extracting("kind.name").contains("CLIENT"); } @@ -365,7 +376,7 @@ public class WebClientTests { span.finish(); } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.spans).isNotEmpty().extracting("kind.name").contains("CLIENT"); } @@ -419,7 +430,7 @@ public class WebClientTests { span.finish(); } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.spans).isNotEmpty(); } @@ -440,7 +451,7 @@ public class WebClientTests { catch (HttpClientErrorException e) { } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); Optional storedSpan = this.spans.spans().stream() .filter(span -> "404".equals(span.tags().get("http.status_code"))) .findFirst(); @@ -461,7 +472,7 @@ public class WebClientTests { public void shouldNotExecuteErrorControllerWhenUrlIsFound() { this.template.getForEntity("http://fooservice/notrace", String.class); - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.testErrorController.getSpan()).isNull(); } @@ -478,7 +489,7 @@ public class WebClientTests { finally { span.finish(); } - then(this.tracer.currentSpan()).isNull(); + thenThereIsNoCurrentSpan(); then(this.customizer.isExecuted()).isTrue(); then(this.spans).extracting("kind.name").contains("CLIENT"); }