This is an automated email from the ASF dual-hosted git repository. adriancole pushed a commit to branch scribe-integration in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git
commit 9236ffa2826ae3cfaa568a66083ccc82c0a56cf8 Author: Adrian Cole <[email protected]> AuthorDate: Wed May 8 20:01:05 2019 +0800 Backfills functional test of Scribe --- zipkin-collector/scribe/pom.xml | 24 ++++++++++++++++ ...beCollectorTest.java => ITScribeCollector.java} | 32 +++++++++++++++++----- .../scribe/src/test/resources/log4j2.properties | 8 ++++++ 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/zipkin-collector/scribe/pom.xml b/zipkin-collector/scribe/pom.xml index a644c67..c325234 100644 --- a/zipkin-collector/scribe/pom.xml +++ b/zipkin-collector/scribe/pom.xml @@ -91,5 +91,29 @@ </exclusion> </exclusions> </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>${log4j.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.zipkin.reporter2</groupId> + <artifactId>zipkin-sender-libthrift</artifactId> + <version>2.8.2</version> + <scope>test</scope> + <exclusions> + <!-- TODO: this exclusion will drift when reporter switches to apache zipkin --> + <exclusion> + <groupId>io.zipkin.zipkin2</groupId> + <artifactId>zipkin</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.thrift</groupId> + <artifactId>libthrift</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> </project> diff --git a/zipkin-collector/scribe/src/test/java/zipkin2/collector/scribe/ScribeCollectorTest.java b/zipkin-collector/scribe/src/test/java/zipkin2/collector/scribe/ITScribeCollector.java similarity index 66% rename from zipkin-collector/scribe/src/test/java/zipkin2/collector/scribe/ScribeCollectorTest.java rename to zipkin-collector/scribe/src/test/java/zipkin2/collector/scribe/ITScribeCollector.java index 26e085f..f6ee974 100644 --- a/zipkin-collector/scribe/src/test/java/zipkin2/collector/scribe/ScribeCollectorTest.java +++ b/zipkin-collector/scribe/src/test/java/zipkin2/collector/scribe/ITScribeCollector.java @@ -16,23 +16,41 @@ */ package zipkin2.collector.scribe; +import java.util.List; import org.jboss.netty.channel.ChannelException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import zipkin2.CheckResult; +import zipkin2.codec.SpanBytesEncoder; +import zipkin2.reporter.libthrift.LibthriftSender; import zipkin2.storage.InMemoryStorage; +import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; +import static zipkin2.TestObjects.TRACE; -public class ScribeCollectorTest { +public class ITScribeCollector { InMemoryStorage storage = InMemoryStorage.newBuilder().build(); @Rule public ExpectedException thrown = ExpectedException.none(); - @Test - public void check_failsWhenNotStarted() { + @Test public void consumesSpans() throws Exception { + List<byte[]> encodedSpans = + TRACE.stream().map(SpanBytesEncoder.THRIFT::encode).collect(toList()); + + try (ScribeCollector server = ScribeCollector.newBuilder().storage(storage).port(12345).build(); + LibthriftSender client = LibthriftSender.newBuilder().host("127.0.0.1").port(12345).build() + ) { + server.start(); + client.sendSpans(encodedSpans).execute(); + } + + assertThat(storage.getTraces()).containsExactly(TRACE); + } + + @Test public void check_failsWhenNotStarted() { try (ScribeCollector scribe = - ScribeCollector.newBuilder().storage(storage).port(12345).build()) { + ScribeCollector.newBuilder().storage(storage).port(12345).build()) { CheckResult result = scribe.check(); assertThat(result.ok()).isFalse(); @@ -43,15 +61,15 @@ public class ScribeCollectorTest { } } - @Test - public void start_failsWhenCantBindPort() { + @Test public void start_failsWhenCantBindPort() { thrown.expect(ChannelException.class); thrown.expectMessage("Failed to bind to: 0.0.0.0/0.0.0.0:12345"); ScribeCollector.Builder builder = ScribeCollector.newBuilder().storage(storage).port(12345); try (ScribeCollector first = builder.build().start()) { - try (ScribeCollector samePort = builder.build().start()) {} + try (ScribeCollector samePort = builder.build().start()) { + } } } } diff --git a/zipkin-collector/scribe/src/test/resources/log4j2.properties b/zipkin-collector/scribe/src/test/resources/log4j2.properties new file mode 100755 index 0000000..a9b5e43 --- /dev/null +++ b/zipkin-collector/scribe/src/test/resources/log4j2.properties @@ -0,0 +1,8 @@ +appenders=console +appender.console.type=Console +appender.console.name=STDOUT +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d{ABSOLUTE} %-5p [%t] %C{2} (%F:%L) - %m%n +rootLogger.level=warn +rootLogger.appenderRefs=stdout +rootLogger.appenderRef.stdout.ref=STDOUT
