diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/servererrors/FeignClientServerErrorTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/servererrors/FeignClientServerErrorTests.java index 846349ebe..651a5f1bc 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/servererrors/FeignClientServerErrorTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/client/feign/servererrors/FeignClientServerErrorTests.java @@ -24,6 +24,9 @@ import brave.Tracing; import brave.sampler.Sampler; import feign.codec.Decoder; import feign.codec.ErrorDecoder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.test.annotation.DirtiesContext; import zipkin2.Span; import org.awaitility.Awaitility; import org.junit.Before; @@ -70,8 +73,11 @@ import static org.assertj.core.api.BDDAssertions.then; @TestPropertySource(properties = { "spring.application.name=fooservice" , "feign.hystrix.enabled=true", "spring.sleuth.http.legacy.enabled=true", "hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=60000"}) +@DirtiesContext public class FeignClientServerErrorTests { + private static final Log log = LogFactory.getLog(FeignClientServerErrorTests.class); + @Autowired TestFeignInterface feignInterface; @Autowired TestFeignWithCustomConfInterface customConfFeignInterface; @Autowired ArrayListSpanReporter reporter; @@ -84,12 +90,14 @@ public class FeignClientServerErrorTests { @Test public void shouldCloseSpanOnInternalServerError() throws InterruptedException { try { + log.info("sending a request"); this.feignInterface.internalError(); } catch (HystrixRuntimeException e) { } Awaitility.await().untilAsserted(() -> { List spans = this.reporter.getSpans(); + log.info("Spans " + spans); Optional spanWithError = spans.stream() .filter(span -> span.tags().containsKey("error")).findFirst(); then(spanWithError.isPresent()).isTrue(); @@ -102,12 +110,14 @@ public class FeignClientServerErrorTests { @Test public void shouldCloseSpanOnNotFound() throws InterruptedException { try { + log.info("sending a request"); this.feignInterface.notFound(); } catch (HystrixRuntimeException e) { } Awaitility.await().untilAsserted(() -> { List spans = this.reporter.getSpans(); + log.info("Spans " + spans); Optional spanWithError = spans.stream() .filter(span -> span.tags().containsKey("http.status_code")).findFirst(); then(spanWithError.isPresent()).isTrue(); @@ -119,12 +129,14 @@ public class FeignClientServerErrorTests { @Test public void shouldCloseSpanOnOk() throws InterruptedException { try { + log.info("sending a request"); this.feignInterface.ok(); } catch (HystrixRuntimeException e) { } Awaitility.await().untilAsserted(() -> { List spans = this.reporter.getSpans(); + log.info("Spans " + spans); then(spans.size()).isGreaterThanOrEqualTo(2); Optional httpSpan = spans.stream() .filter(span -> span.tags().containsKey("http.method")).findFirst(); @@ -137,12 +149,14 @@ public class FeignClientServerErrorTests { @Test public void shouldCloseSpanOnOkWithCustomFeignConfiguration() throws InterruptedException { try { + log.info("sending a request"); this.customConfFeignInterface.ok(); } catch (HystrixRuntimeException e) { } Awaitility.await().untilAsserted(() -> { List spans = this.reporter.getSpans(); + log.info("Spans " + spans); then(spans.size()).isGreaterThanOrEqualTo(2); Optional httpSpan = spans.stream() .filter(span -> span.tags().containsKey("http.method")).findFirst(); @@ -155,12 +169,14 @@ public class FeignClientServerErrorTests { @Test public void shouldCloseSpanOnNotFoundWithCustomFeignConfiguration() throws InterruptedException { try { + log.info("sending a request"); this.customConfFeignInterface.notFound(); } catch (HystrixRuntimeException e) { } Awaitility.await().untilAsserted(() -> { List spans = this.reporter.getSpans(); + log.info("Spans " + spans); Optional spanWithError = spans.stream() .filter(span -> span.tags().containsKey("error")).findFirst(); then(spanWithError.isPresent()).isTrue();