Make a test case for span limit. (#2157)
This commit is contained in:
parent
b5eb9e304d
commit
cee0525f74
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue