From 5676f3369a68d7202f079356fe04d6601a540808 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 2 Mar 2018 09:20:17 +0100 Subject: [PATCH] Fixed tests for snapshot brave --- .../sleuth/instrument/web/TraceFilterTests.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java index 58251c27f..d682fc0de 100644 --- a/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java +++ b/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterTests.java @@ -459,14 +459,15 @@ public class TraceFilterTests { filter.doFilter(this.request, this.response, this.filterChain); then(Tracing.current().tracer().currentSpan()).isNull(); - // Brave doesn't work like Sleuth. No trace will be created for an invalid span - // where invalid means that there is no trace id - then(this.reporter.getSpans()).isEmpty(); + // It is ok to go without a trace ID, if sampling or debug is set + then(this.reporter.getSpans()) + .hasSize(1) + .extracting("id").isNotEqualTo(SpanUtil.idToHex(10L)); } @SuppressWarnings("Duplicates") @Test - public void samplesWhenDebugFlagIsSetTo1AndTraceIdIsAlsoSet() throws Exception { + public void usesSamplingMechanismWhenIncomingTraceIsMalformed() throws Exception { this.request = builder() .header(SPAN_FLAGS, 1) .header(TRACE_ID_NAME, SpanUtil.idToHex(10L)) @@ -476,11 +477,7 @@ public class TraceFilterTests { filter.doFilter(this.request, this.response, this.filterChain); then(Tracing.current().tracer().currentSpan()).isNull(); - then(this.reporter.getSpans()) - .hasSize(1); - // Brave creates a new trace if there was no span id - then(this.reporter.getSpans().get(0).traceId()) - .isNotEqualTo(SpanUtil.idToHex(10L)); + then(this.reporter.getSpans()).isEmpty(); } // #668