You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/01/14 08:46:34 UTC
[incubator-skywalking] branch master updated: Make a test case for
span limit. (#2157)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new cee0525 Make a test case for span limit. (#2157)
cee0525 is described below
commit cee0525f747f912c5388e511c8df57c2cd679726
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Mon Jan 14 16:46:28 2019 +0800
Make a test case for span limit. (#2157)
---
.../apm/agent/core/remote/GRPCChannelManager.java | 25 +++-----
.../apm/agent/core/context/TracingContextTest.java | 66 ++++++++++++++++++++++
2 files changed, 74 insertions(+), 17 deletions(-)
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
index c6f7cc0..4334f45 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/GRPCChannelManager.java
@@ -18,23 +18,12 @@
package org.apache.skywalking.apm.agent.core.remote;
-import io.grpc.Channel;
-import io.grpc.Status;
-import io.grpc.StatusRuntimeException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import org.apache.skywalking.apm.agent.core.boot.BootService;
-import org.apache.skywalking.apm.agent.core.boot.DefaultImplementor;
-import org.apache.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory;
+import io.grpc.*;
+import java.util.*;
+import java.util.concurrent.*;
+import org.apache.skywalking.apm.agent.core.boot.*;
import org.apache.skywalking.apm.agent.core.conf.Config;
-import org.apache.skywalking.apm.agent.core.logging.api.ILog;
-import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
+import org.apache.skywalking.apm.agent.core.logging.api.*;
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
/**
@@ -81,7 +70,9 @@ public class GRPCChannelManager implements BootService, Runnable {
@Override
public void shutdown() throws Throwable {
- connectCheckFuture.cancel(true);
+ if (connectCheckFuture != null) {
+ connectCheckFuture.cancel(true);
+ }
if (managedChannel != null) {
managedChannel.shutdownNow();
}
diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/TracingContextTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/TracingContextTest.java
new file mode 100644
index 0000000..ae33e95
--- /dev/null
+++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/TracingContextTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.agent.core.context;
+
+import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
+import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig;
+import org.apache.skywalking.apm.agent.core.context.trace.*;
+import org.junit.*;
+
+public class TracingContextTest {
+ @BeforeClass
+ public static void setup() {
+ ServiceManager.INSTANCE.boot();
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = 5;
+ }
+
+ @AfterClass
+ public static void clear() {
+ RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = 0;
+ ServiceManager.INSTANCE.shutdown();
+ }
+
+ @Test
+ public void testSpanLimit() {
+ final boolean[] dataReceived = {false};
+ TracingContext.ListenerManager.add(new TracingContextListener() {
+ @Override public void afterFinished(TraceSegment traceSegment) {
+ dataReceived[0] = true;
+ }
+ });
+ TracingContext tracingContext = new TracingContext();
+ AbstractSpan span = tracingContext.createEntrySpan("/url");
+
+ for (int i = 0; i < 10; i++) {
+ AbstractSpan localSpan = tracingContext.createLocalSpan("/java-bean");
+
+ for (int j = 0; j < 100; j++) {
+ AbstractSpan exitSpan = tracingContext.createExitSpan("/redis","localhost");
+ tracingContext.stopSpan(exitSpan);
+ }
+
+ tracingContext.stopSpan(localSpan);
+ }
+
+ tracingContext.stopSpan(span);
+
+
+ Assert.assertTrue(dataReceived[0]);
+ }
+}