Removes Zipkin dependency from all tests (#1645)
Brave's SpanHandler can report natively in other formats which have different constraints than Zipkin and often extensions to the data model. This change ports all tests away from Zipkin's types so that it is more clear what's actually recorded vs what's a side-effect of Zipkin conversion. This removes `BlockingQueueSpanReporter` which was never released, also.
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.concurrent.ThreadFactory;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.test.TestSpanHandler;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -38,8 +39,6 @@ import rx.plugins.RxJavaObservableExecutionHook;
|
||||
import rx.plugins.RxJavaPlugins;
|
||||
import rx.plugins.RxJavaSchedulersHook;
|
||||
|
||||
import org.springframework.cloud.sleuth.util.ArrayListSpanReporter;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
/**
|
||||
@@ -53,17 +52,17 @@ public class SleuthRxJavaSchedulersHookTests {
|
||||
|
||||
StrictCurrentTraceContext currentTraceContext = StrictCurrentTraceContext.create();
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
TestSpanHandler spans = new TestSpanHandler();
|
||||
|
||||
Tracing tracing = Tracing.newBuilder().currentTraceContext(this.currentTraceContext)
|
||||
.spanReporter(this.reporter).build();
|
||||
.addSpanHandler(this.spans).build();
|
||||
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
this.tracing.close();
|
||||
this.reporter.clear();
|
||||
this.spans.clear();
|
||||
this.currentTraceContext.close();
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ public class SleuthRxJavaSchedulersHookTests {
|
||||
|
||||
then(action).isInstanceOf(SleuthRxJavaSchedulersHook.TraceAction.class);
|
||||
then(caller.toString()).isEqualTo("called_from_schedulers_hook");
|
||||
then(this.reporter.getSpans()).isNotEmpty();
|
||||
then(this.spans).isNotEmpty();
|
||||
then(this.tracer.currentSpan()).isNull();
|
||||
}
|
||||
|
||||
@@ -122,7 +121,7 @@ public class SleuthRxJavaSchedulersHookTests {
|
||||
|
||||
hello.get();
|
||||
|
||||
then(this.reporter.getSpans()).isEmpty();
|
||||
then(this.spans).isEmpty();
|
||||
then(this.tracer.currentSpan()).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@ package org.springframework.cloud.sleuth.instrument.rxjava;
|
||||
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.handler.SpanHandler;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.test.TestSpanHandler;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -32,7 +34,6 @@ import rx.schedulers.Schedulers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.sleuth.util.ArrayListSpanReporter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -48,7 +49,7 @@ import static org.awaitility.Awaitility.await;
|
||||
public class SleuthRxJavaTests {
|
||||
|
||||
@Autowired
|
||||
ArrayListSpanReporter reporter;
|
||||
TestSpanHandler spans;
|
||||
|
||||
@Autowired
|
||||
Tracer tracer;
|
||||
@@ -63,7 +64,7 @@ public class SleuthRxJavaTests {
|
||||
|
||||
@Before
|
||||
public void clean() {
|
||||
this.reporter.clear();
|
||||
this.spans.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,11 +77,9 @@ public class SleuthRxJavaTests {
|
||||
|
||||
then(this.caller.toString()).isEqualTo("actual_action");
|
||||
then(this.tracer.currentSpan()).isNull();
|
||||
await().atMost(5, SECONDS)
|
||||
.untilAsserted(() -> then(this.reporter.getSpans()).hasSize(1));
|
||||
then(this.reporter.getSpans()).hasSize(1);
|
||||
zipkin2.Span span = this.reporter.getSpans().get(0);
|
||||
then(span.name()).isEqualTo("rxjava");
|
||||
await().atMost(5, SECONDS).untilAsserted(() -> then(this.spans).hasSize(1));
|
||||
then(this.spans).hasSize(1);
|
||||
then(this.spans.get(0).name()).isEqualTo("rxjava");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,9 +99,8 @@ public class SleuthRxJavaTests {
|
||||
then(this.caller.toString()).isEqualTo("actual_action");
|
||||
then(this.tracer.currentSpan()).isNull();
|
||||
// making sure here that no new spans were created or reported as closed
|
||||
then(this.reporter.getSpans()).hasSize(1);
|
||||
zipkin2.Span span = this.reporter.getSpans().get(0);
|
||||
then(span.name()).isEqualTo("current_span");
|
||||
then(this.spans).hasSize(1);
|
||||
then(this.spans.get(0).name()).isEqualTo("current_span");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -115,8 +113,8 @@ public class SleuthRxJavaTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
ArrayListSpanReporter spanReporter() {
|
||||
return new ArrayListSpanReporter();
|
||||
SpanHandler testSpanHandler() {
|
||||
return new TestSpanHandler();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user