This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch zipkin
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/zipkin by this push:
new bafcc23 Set the first test case.
bafcc23 is described below
commit bafcc2325743580778cd38b0981645b813d53825
Author: Wu Sheng <[email protected]>
AuthorDate: Tue Jul 14 22:01:07 2020 +0800
Set the first test case.
---
.../zipkin-reporter-plugin/pom.xml | 34 +++++++--
.../plugin/reporter/zipkin/ZipkinTracingTest.java | 82 ++++++++++++++++++++++
2 files changed, 109 insertions(+), 7 deletions(-)
diff --git
a/apm-sniffer/optional-reporter-plugins/zipkin-reporter-plugin/pom.xml
b/apm-sniffer/optional-reporter-plugins/zipkin-reporter-plugin/pom.xml
index 25e24ff..3c900af 100644
--- a/apm-sniffer/optional-reporter-plugins/zipkin-reporter-plugin/pom.xml
+++ b/apm-sniffer/optional-reporter-plugins/zipkin-reporter-plugin/pom.xml
@@ -34,9 +34,10 @@
<packaging>jar</packaging>
<properties>
- <zipkin.version>5.12.3</zipkin.version>
- <zipkin.okhttp3.version>2.15.0</zipkin.okhttp3.version>
+ <zipkin.brave.version>5.12.3</zipkin.brave.version>
+ <zipkin.sender.okhttp3.version>2.15.0</zipkin.sender.okhttp3.version>
<zipkin.reporter.brave.version>2.15.0</zipkin.reporter.brave.version>
+ <zipkin.server.version>2.21.5</zipkin.server.version>
<shade.brave.source>brave</shade.brave.source>
<shade.brave.target>${shade.package}.${shade.brave.source}</shade.brave.target>
@@ -52,33 +53,52 @@
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave</artifactId>
- <version>${zipkin.version}</version>
+ <version>${zipkin.brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-http</artifactId>
- <version>${zipkin.version}</version>
+ <version>${zipkin.brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-rpc</artifactId>
- <version>${zipkin.version}</version>
+ <version>${zipkin.brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-messaging</artifactId>
- <version>${zipkin.version}</version>
+ <version>${zipkin.brave.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-sender-okhttp3</artifactId>
- <version>${zipkin.okhttp3.version}</version>
+ <version>${zipkin.sender.okhttp3.version}</version>
</dependency>
<dependency>
<groupId>io.zipkin.reporter2</groupId>
<artifactId>zipkin-reporter-brave</artifactId>
<version>${zipkin.reporter.brave.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>io.zipkin.zipkin2</groupId>
+ <artifactId>zipkin-junit</artifactId>
+ <version>${zipkin.server.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>mockwebserver</artifactId>
+ <version>3.14.9</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git
a/apm-sniffer/optional-reporter-plugins/zipkin-reporter-plugin/src/test/java/org/apache/skywalking/apm/plugin/reporter/zipkin/ZipkinTracingTest.java
b/apm-sniffer/optional-reporter-plugins/zipkin-reporter-plugin/src/test/java/org/apache/skywalking/apm/plugin/reporter/zipkin/ZipkinTracingTest.java
new file mode 100644
index 0000000..cb53d1a
--- /dev/null
+++
b/apm-sniffer/optional-reporter-plugins/zipkin-reporter-plugin/src/test/java/org/apache/skywalking/apm/plugin/reporter/zipkin/ZipkinTracingTest.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.reporter.zipkin;
+
+import java.util.List;
+import org.apache.skywalking.apm.agent.core.conf.Config;
+import org.apache.skywalking.apm.agent.core.context.AbstractTracerContext;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+import zipkin2.Span;
+import zipkin2.junit.ZipkinRule;
+
+public class ZipkinTracingTest {
+ @Rule
+ public ZipkinRule zipkin = new ZipkinRule();
+
+ @Before
+ public void setup() {
+ Config.Collector.BACKEND_SERVICE = zipkin.httpUrl() + "/api/v2/spans";
+ Config.Agent.SERVICE_NAME = "Zipkin-Core";
+ }
+
+ @After
+ public void clean() {
+ Config.Collector.BACKEND_SERVICE = null;
+ Config.Agent.SERVICE_NAME = null;
+ }
+
+ @Test
+ public void zipkinTracerRunning() throws Exception {
+ final ZipkinTraceReporter zipkinTraceReporter = new
ZipkinTraceReporter();
+ zipkinTraceReporter.boot();
+
+ ZipkinContextManager manager = new ZipkinContextManager();
+ Whitebox.setInternalState(manager, "zipkinTraceReporter",
zipkinTraceReporter);
+ final AbstractTracerContext traceContext =
manager.createTraceContext("/span1", true);
+ Assert.assertTrue(traceContext instanceof ZipkinTracerContext);
+
+ final AbstractSpan span1 = traceContext.createEntrySpan("span1");
+ final AbstractSpan span2 = traceContext.createLocalSpan("span2");
+ final AbstractSpan span3 = traceContext.createExitSpan("span3",
"127.0.0.1:8080");
+
+ traceContext.stopSpan(span3);
+ traceContext.stopSpan(span2);
+ traceContext.stopSpan(span1);
+
+ List<List<Span>> traces = null;
+ boolean received = false;
+ for (int i = 10; i >= 0; i--) {
+ Thread.sleep(2000L);
+ traces = zipkin.getTraces();
+ if (traces.size() > 0) {
+ received = true;
+ break;
+ }
+ }
+
+ Assert.assertTrue(received);
+ Assert.assertEquals(1, traces.size());
+ }
+}