This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 190d664 add agent tracing test (#8910)
190d664 is described below
commit 190d66495ea798024b782d96fe4ca71a9d007797
Author: xiaoyu <[email protected]>
AuthorDate: Wed Jan 6 16:11:47 2021 +0800
add agent tracing test (#8910)
---
.../service/JaegerTracingPluginBootService.java | 11 ++++-
.../advice/CommandExecutorTaskAdviceTest.java | 7 ++-
.../advice/JDBCExecutorCallbackAdviceTest.java | 4 +-
.../jaeger/advice/SQLParserEngineAdviceTest.java | 9 ++--
.../JaegerPluginDefinitionServiceTest.java | 41 ++++++++++++++++
.../JaegerTracingPluginBootServiceTest.java | 55 +++++++++++++++++++++
.../pom.xml | 6 +++
.../advice/CommandExecutorTaskAdviceTest.java | 16 +++---
.../advice/JDBCExecutorCallbackAdviceTest.java | 17 +++----
.../opentracing/advice/MockTargetObject.java | 35 +++++++++++++
.../advice/SQLParserEngineAdviceTest.java | 23 +++++----
.../OpenTracingPluginDefinitionServiceTest.java | 41 ++++++++++++++++
.../service/OpenTracingPluginBootServiceTest.java | 52 ++++++++++++++++++++
.../{AdviceTestBase.java => AdviceBaseTest.java} | 2 +-
.../advice/CommandExecutorTaskAdviceTest.java | 2 +-
.../advice/JDBCExecutorCallbackAdviceTest.java | 2 +-
.../zipkin/advice/SQLParserEngineAdviceTest.java | 2 +-
.../ZipkinPluginDefinitionServiceTest.java | 41 ++++++++++++++++
.../ZipkinTracingPluginBootServiceTest.java | 57 ++++++++++++++++++++++
19 files changed, 376 insertions(+), 47 deletions(-)
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
index f66c22d..b3d25b1 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootService.java
@@ -27,14 +27,18 @@ import
org.apache.shardingsphere.agent.spi.boot.PluginBootService;
*/
public final class JaegerTracingPluginBootService implements PluginBootService
{
+ private Configuration configuration;
+
@Override
public void start(final PluginConfiguration pluginConfig) {
pluginConfig.getProps().forEach((key, value) ->
System.setProperty(String.valueOf(key), String.valueOf(value)));
Configuration.SamplerConfiguration samplerConfig =
Configuration.SamplerConfiguration.fromEnv();
Configuration.ReporterConfiguration reporterConfig =
Configuration.ReporterConfiguration.fromEnv()
.withSender(Configuration.SenderConfiguration.fromEnv().withAgentHost(pluginConfig.getHost()).withAgentPort(pluginConfig.getPort()));
- Configuration config = new
Configuration("ShardingSphere-Jaeger").withSampler(samplerConfig).withReporter(reporterConfig);
- GlobalTracer.register(config.getTracer());
+ configuration = new
Configuration("ShardingSphere-Jaeger").withSampler(samplerConfig).withReporter(reporterConfig);
+ if (!GlobalTracer.isRegistered()) {
+ GlobalTracer.register(configuration.getTracer());
+ }
}
@Override
@@ -44,5 +48,8 @@ public final class JaegerTracingPluginBootService implements
PluginBootService {
@Override
public void close() {
+ if (null != configuration) {
+ configuration.closeTracer();
+ }
}
}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
index ccbe09c..a60d028 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
@@ -66,8 +66,8 @@ public final class CommandExecutorTaskAdviceTest {
}
@Test
- public void testMethod() {
- final MockTargetObject targetObject = new MockTargetObject();
+ public void assertMethod() {
+ MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, executeCommandMethod, new
Object[]{}, new MethodInvocationResult());
ADVICE.afterMethod(targetObject, executeCommandMethod, new Object[]{},
new MethodInvocationResult());
List<MockSpan> spans = tracer.finishedSpans();
@@ -77,7 +77,7 @@ public final class CommandExecutorTaskAdviceTest {
}
@Test
- public void testExceptionHandle() {
+ public void assertExceptionHandle() {
MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, executeCommandMethod, new
Object[]{}, new MethodInvocationResult());
ADVICE.onThrowing(targetObject, executeCommandMethod, new Object[]{},
new IOException());
@@ -94,5 +94,4 @@ public final class CommandExecutorTaskAdviceTest {
assertThat(fields.get("error.kind"), is("java.io.IOException"));
assertThat(span.operationName(), is("/ShardingSphere/rootInvoke/"));
}
-
}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/JDBCExecutorCallbackAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/JDBCExecutorCallbackAdviceTest.java
index 4ac7e17..ce5ad13 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/JDBCExecutorCallbackAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/JDBCExecutorCallbackAdviceTest.java
@@ -69,7 +69,7 @@ public final class JDBCExecutorCallbackAdviceTest {
}
@Test
- public void testMethod() {
+ public void assertMethod() {
MockTargetObject targetObject = new MockTargetObject();
Map<String, Object> extraMap = Maps.newHashMap();
extraMap.put("_root_span_", null);
@@ -90,7 +90,7 @@ public final class JDBCExecutorCallbackAdviceTest {
}
@Test
- public void testExceptionHandle() {
+ public void assertExceptionHandle() {
MockTargetObject targetObject = new MockTargetObject();
Map<String, Object> extraMap = Maps.newHashMap();
extraMap.put("_root_span_", null);
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
index 95759ab..f62aefe 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
@@ -23,7 +23,6 @@ import io.opentracing.util.GlobalTracer;
import org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
import
org.apache.shardingsphere.agent.plugin.tracing.jaeger.constant.ErrorLogTagKeys;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -61,8 +60,8 @@ public final class SQLParserEngineAdviceTest {
}
@Test
- public void testMethod() {
- final MockTargetObject targetObject = new MockTargetObject();
+ public void assertMethod() {
+ MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, parserMethod, new Object[]{"select
1"}, new MethodInvocationResult());
ADVICE.afterMethod(targetObject, parserMethod, new Object[]{}, new
MethodInvocationResult());
List<MockSpan> spans = tracer.finishedSpans();
@@ -72,7 +71,7 @@ public final class SQLParserEngineAdviceTest {
}
@Test
- public void testExceptionHandle() {
+ public void assertExceptionHandle() {
MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, parserMethod, new Object[]{"select
1"}, new MethodInvocationResult());
ADVICE.onThrowing(targetObject, parserMethod, new Object[]{}, new
IOException());
@@ -80,7 +79,7 @@ public final class SQLParserEngineAdviceTest {
List<MockSpan> spans = tracer.finishedSpans();
assertThat(spans.size(), is(1));
MockSpan span = spans.get(0);
- Assert.assertTrue((boolean) span.tags().get("error"));
+ assertThat(span.tags().get("error"), is(true));
List<MockSpan.LogEntry> entries = span.logEntries();
assertThat(entries.size(), is(1));
Map<String, ?> fields = entries.get(0).fields();
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/definition/JaegerPluginDefinitionServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/definition/JaegerPluginDefinitionServiceTest.java
new file mode 100644
index 0000000..0c84700
--- /dev/null
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/definition/JaegerPluginDefinitionServiceTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.shardingsphere.agent.plugin.tracing.jaeger.definition;
+
+import java.util.List;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class JaegerPluginDefinitionServiceTest {
+
+ private final JaegerPluginDefinitionService jaegerPluginDefinitionService
= new JaegerPluginDefinitionService();
+
+ @Test
+ public void assertDefine() {
+ List<PluginInterceptorPoint> interceptorPointList =
jaegerPluginDefinitionService.build();
+ assertThat(interceptorPointList.size(), is(3));
+ }
+
+ @Test
+ public void assertType() {
+ assertThat(jaegerPluginDefinitionService.getType(), is("Jaeger"));
+ }
+}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
new file mode 100644
index 0000000..535627e
--- /dev/null
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.shardingsphere.agent.plugin.tracing.jaeger.service;
+
+import io.opentracing.util.GlobalTracer;
+import java.util.Properties;
+import org.apache.shardingsphere.agent.config.PluginConfiguration;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class JaegerTracingPluginBootServiceTest {
+
+ private final JaegerTracingPluginBootService
jaegerTracingPluginBootService = new JaegerTracingPluginBootService();
+
+ @Test
+ public void assertStart() {
+ Properties props = new Properties();
+ props.setProperty("JAEGER_SAMPLER_TYPE", "const");
+ props.setProperty("JAEGER_SAMPLER_PARAM", "1");
+ props.setProperty("JAEGER_REPORTER_LOG_SPANS", "true");
+ props.setProperty("JAEGER_REPORTER_FLUSH_INTERVAL", "1");
+ PluginConfiguration configuration = new PluginConfiguration();
+ configuration.setProps(props);
+ jaegerTracingPluginBootService.start(configuration);
+ assertThat(GlobalTracer.isRegistered(), is(true));
+ }
+
+ @Test
+ public void assertType() {
+ assertThat(jaegerTracingPluginBootService.getType(), is("Jaeger"));
+ }
+
+ @After
+ public void close() {
+ jaegerTracingPluginBootService.close();
+ }
+}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/pom.xml
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/pom.xml
index 982f8fc..e6a560e 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/pom.xml
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/pom.xml
@@ -48,6 +48,12 @@
<artifactId>opentracing-mock</artifactId>
<version>${opentracing.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-proxy-frontend-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
similarity index 96%
copy from
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
copy to
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
index ccbe09c..c4fd85a 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
@@ -15,12 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice;
+package org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice;
import io.netty.channel.ChannelHandlerContext;
import io.opentracing.mock.MockSpan;
import io.opentracing.mock.MockTracer;
import io.opentracing.util.GlobalTracer;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
import lombok.SneakyThrows;
import org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
@@ -32,11 +36,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.internal.util.reflection.FieldReader;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
@@ -66,7 +65,7 @@ public final class CommandExecutorTaskAdviceTest {
}
@Test
- public void testMethod() {
+ public void assertMethod() {
final MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, executeCommandMethod, new
Object[]{}, new MethodInvocationResult());
ADVICE.afterMethod(targetObject, executeCommandMethod, new Object[]{},
new MethodInvocationResult());
@@ -77,7 +76,7 @@ public final class CommandExecutorTaskAdviceTest {
}
@Test
- public void testExceptionHandle() {
+ public void assertExceptionHandle() {
MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, executeCommandMethod, new
Object[]{}, new MethodInvocationResult());
ADVICE.onThrowing(targetObject, executeCommandMethod, new Object[]{},
new IOException());
@@ -94,5 +93,4 @@ public final class CommandExecutorTaskAdviceTest {
assertThat(fields.get("error.kind"), is("java.io.IOException"));
assertThat(span.operationName(), is("/ShardingSphere/rootInvoke/"));
}
-
}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/JDBCExecutorCallbackAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/JDBCExecutorCallbackAdviceTest.java
similarity index 95%
copy from
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/JDBCExecutorCallbackAdviceTest.java
copy to
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/JDBCExecutorCallbackAdviceTest.java
index 4ac7e17..1713943 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/JDBCExecutorCallbackAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/JDBCExecutorCallbackAdviceTest.java
@@ -15,16 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice;
+package org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.opentracing.mock.MockSpan;
import io.opentracing.mock.MockTracer;
import io.opentracing.util.GlobalTracer;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
import lombok.SneakyThrows;
import org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
-import
org.apache.shardingsphere.agent.plugin.tracing.jaeger.constant.ErrorLogTagKeys;
+import
org.apache.shardingsphere.agent.plugin.tracing.opentracing.constant.ErrorLogTagKeys;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.context.SQLUnit;
import
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
@@ -34,11 +38,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.internal.util.reflection.FieldReader;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
@@ -69,7 +68,7 @@ public final class JDBCExecutorCallbackAdviceTest {
}
@Test
- public void testMethod() {
+ public void assertMethod() {
MockTargetObject targetObject = new MockTargetObject();
Map<String, Object> extraMap = Maps.newHashMap();
extraMap.put("_root_span_", null);
@@ -90,7 +89,7 @@ public final class JDBCExecutorCallbackAdviceTest {
}
@Test
- public void testExceptionHandle() {
+ public void assertExceptionHandle() {
MockTargetObject targetObject = new MockTargetObject();
Map<String, Object> extraMap = Maps.newHashMap();
extraMap.put("_root_span_", null);
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/MockTargetObject.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/MockTargetObject.java
new file mode 100644
index 0000000..1ab8352
--- /dev/null
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/MockTargetObject.java
@@ -0,0 +1,35 @@
+/*
+ * 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.shardingsphere.agent.plugin.tracing.opentracing.advice;
+
+import org.apache.shardingsphere.agent.api.advice.TargetObject;
+
+public final class MockTargetObject implements TargetObject {
+
+ private Object object;
+
+ @Override
+ public Object getAttachment() {
+ return object;
+ }
+
+ @Override
+ public void setAttachment(final Object attachment) {
+ this.object = attachment;
+ }
+}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/SQLParserEngineAdviceTest.java
similarity index 90%
copy from
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
copy to
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/SQLParserEngineAdviceTest.java
index 95759ab..a721b85 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/SQLParserEngineAdviceTest.java
@@ -15,25 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.tracing.jaeger.advice;
+package org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice;
import io.opentracing.mock.MockSpan;
import io.opentracing.mock.MockTracer;
import io.opentracing.util.GlobalTracer;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
import org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
-import
org.apache.shardingsphere.agent.plugin.tracing.jaeger.constant.ErrorLogTagKeys;
+import
org.apache.shardingsphere.agent.plugin.tracing.opentracing.constant.ErrorLogTagKeys;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
-import org.junit.Assert;
+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.internal.util.reflection.FieldReader;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -61,8 +60,8 @@ public final class SQLParserEngineAdviceTest {
}
@Test
- public void testMethod() {
- final MockTargetObject targetObject = new MockTargetObject();
+ public void assertMethod() {
+ MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, parserMethod, new Object[]{"select
1"}, new MethodInvocationResult());
ADVICE.afterMethod(targetObject, parserMethod, new Object[]{}, new
MethodInvocationResult());
List<MockSpan> spans = tracer.finishedSpans();
@@ -72,7 +71,7 @@ public final class SQLParserEngineAdviceTest {
}
@Test
- public void testExceptionHandle() {
+ public void assertExceptionHandle() {
MockTargetObject targetObject = new MockTargetObject();
ADVICE.beforeMethod(targetObject, parserMethod, new Object[]{"select
1"}, new MethodInvocationResult());
ADVICE.onThrowing(targetObject, parserMethod, new Object[]{}, new
IOException());
@@ -80,7 +79,7 @@ public final class SQLParserEngineAdviceTest {
List<MockSpan> spans = tracer.finishedSpans();
assertThat(spans.size(), is(1));
MockSpan span = spans.get(0);
- Assert.assertTrue((boolean) span.tags().get("error"));
+ assertThat(span.tags().get("error"), is(true));
List<MockSpan.LogEntry> entries = span.logEntries();
assertThat(entries.size(), is(1));
Map<String, ?> fields = entries.get(0).fields();
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/definition/OpenTracingPluginDefinitionServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/definition/OpenTracingP
[...]
new file mode 100644
index 0000000..d2fb4a0
--- /dev/null
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/definition/OpenTracingPluginDefinitionServiceTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.shardingsphere.agent.plugin.tracing.opentracing.definition;
+
+import java.util.List;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class OpenTracingPluginDefinitionServiceTest {
+
+ private final OpenTracingPluginDefinitionService
openTracingPluginDefinitionService = new OpenTracingPluginDefinitionService();
+
+ @Test
+ public void assertDefine() {
+ List<PluginInterceptorPoint> interceptorPointList =
openTracingPluginDefinitionService.build();
+ assertThat(interceptorPointList.size(), is(3));
+ }
+
+ @Test
+ public void assertType() {
+ assertThat(openTracingPluginDefinitionService.getType(),
is("Opentracing"));
+ }
+}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootSer
[...]
new file mode 100644
index 0000000..ff6e672
--- /dev/null
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.shardingsphere.agent.plugin.tracing.opentracing.service;
+
+import io.opentracing.util.GlobalTracer;
+import java.util.Properties;
+import org.apache.shardingsphere.agent.config.PluginConfiguration;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class OpenTracingPluginBootServiceTest {
+
+ private final OpenTracingPluginBootService openTracingPluginBootService =
new OpenTracingPluginBootService();
+
+ @Test
+ public void assertStart() {
+ Properties props = new Properties();
+ props.setProperty("OPENTRACING_TRACER_CLASS_NAME",
"io.opentracing.mock.MockTracer");
+ PluginConfiguration configuration = new PluginConfiguration();
+ configuration.setProps(props);
+ openTracingPluginBootService.start(configuration);
+ assertThat(GlobalTracer.isRegistered(), is(true));
+ }
+
+ @Test
+ public void assertType() {
+ assertThat(openTracingPluginBootService.getType(), is("Opentracing"));
+ }
+
+ @After
+ public void close() {
+ openTracingPluginBootService.close();
+ }
+}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/AdviceTestBase.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/AdviceBaseTest.java
similarity index 98%
rename from
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/AdviceTestBase.java
rename to
shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/AdviceBaseTest.java
index fa5470f..3ec3599 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/AdviceTestBase.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/AdviceBaseTest.java
@@ -31,7 +31,7 @@ import zipkin2.Span;
import java.util.concurrent.ConcurrentLinkedDeque;
-public abstract class AdviceTestBase {
+public abstract class AdviceBaseTest {
public static final ConcurrentLinkedDeque<Span> SPANS = new
ConcurrentLinkedDeque<>();
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdviceTest.java
index 9521012..60412c3 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/CommandExecutorTaskAdviceTest.java
@@ -40,7 +40,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-public final class CommandExecutorTaskAdviceTest extends AdviceTestBase {
+public final class CommandExecutorTaskAdviceTest extends AdviceBaseTest {
private static Method executeCommandMethod;
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdviceTest.java
index 935f7fd..c0fe839 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdviceTest.java
@@ -49,7 +49,7 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public final class JDBCExecutorCallbackAdviceTest extends AdviceTestBase {
+public final class JDBCExecutorCallbackAdviceTest extends AdviceBaseTest {
private static Method executeMethod;
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/SQLParserEngineAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/SQLParserEngineAdviceTest.java
index 4579269..70eb382 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/SQLParserEngineAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/SQLParserEngineAdviceTest.java
@@ -39,7 +39,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
-public final class SQLParserEngineAdviceTest extends AdviceTestBase {
+public final class SQLParserEngineAdviceTest extends AdviceBaseTest {
private static final String SQL_STMT = "select 1";
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/definition/ZipkinPluginDefinitionServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/definition/ZipkinPluginDefinitionServiceTest.java
new file mode 100644
index 0000000..66582de
--- /dev/null
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/definition/ZipkinPluginDefinitionServiceTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.shardingsphere.agent.plugin.tracing.zipkin.definition;
+
+import java.util.List;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class ZipkinPluginDefinitionServiceTest {
+
+ private final ZipkinPluginDefinitionService zipkinPluginDefinitionService
= new ZipkinPluginDefinitionService();
+
+ @Test
+ public void assertDefine() {
+ List<PluginInterceptorPoint> interceptorPointList =
zipkinPluginDefinitionService.build();
+ assertThat(interceptorPointList.size(), is(3));
+ }
+
+ @Test
+ public void assertType() {
+ assertThat(zipkinPluginDefinitionService.getType(), is("Zipkin"));
+ }
+}
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootServiceTest.java
new file mode 100644
index 0000000..8aa63c7
--- /dev/null
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/service/ZipkinTracingPluginBootServiceTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.shardingsphere.agent.plugin.tracing.zipkin.service;
+
+import brave.Tracing;
+import java.lang.reflect.Field;
+import lombok.SneakyThrows;
+import org.apache.shardingsphere.agent.config.PluginConfiguration;
+
+import org.junit.AfterClass;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public final class ZipkinTracingPluginBootServiceTest {
+
+ private static ZipkinTracingPluginBootService
zipkinTracingPluginBootService = new ZipkinTracingPluginBootService();
+
+ @SneakyThrows
+ @Test
+ public void assertStart() {
+ PluginConfiguration configuration = new PluginConfiguration();
+ configuration.setPort(9441);
+ zipkinTracingPluginBootService.start(configuration);
+ Field field =
ZipkinTracingPluginBootService.class.getDeclaredField("tracing");
+ field.setAccessible(true);
+ Tracing tracing = (Tracing) field.get(zipkinTracingPluginBootService);
+ assertNotNull(tracing.tracer());
+ }
+
+ @Test
+ public void assertType() {
+ assertThat(zipkinTracingPluginBootService.getType(), is("Zipkin"));
+ }
+
+ @AfterClass
+ public static void close() {
+ zipkinTracingPluginBootService.close();
+ }
+}