From 0bf535e861389fcd82f82f0dd3f1aade6a3dac3f Mon Sep 17 00:00:00 2001 From: jiangyuan Date: Sun, 12 May 2024 11:37:55 +0800 Subject: [PATCH] Fix TracingSegmentRunner (testing only) (#688) --- .../apm/agent/core/test/tools/TracingSegmentRunner.java | 4 +++- .../skywalking/apm/agent/test/tools/TracingSegmentRunner.java | 4 +++- ...eterContextSnapshotThreadLocalAccessorInterceptorTest.java | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/test/tools/TracingSegmentRunner.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/test/tools/TracingSegmentRunner.java index 1b88070fda..a9fa848e21 100644 --- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/test/tools/TracingSegmentRunner.java +++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/test/tools/TracingSegmentRunner.java @@ -55,7 +55,7 @@ protected Object createTest() throws Exception { @Override protected Statement withAfters(FrameworkMethod method, Object target, final Statement statement) { - return new Statement() { + Statement st = new Statement() { @Override public void evaluate() throws Throwable { if (field != null) { @@ -89,5 +89,7 @@ public void afterFinished(IgnoredTracerContext tracerContext) { } } }; + + return super.withAfters(method, target, st); } } diff --git a/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/TracingSegmentRunner.java b/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/TracingSegmentRunner.java index 0626f36d01..8dbb6cf1a3 100644 --- a/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/TracingSegmentRunner.java +++ b/apm-sniffer/apm-test-tools/src/main/java/org/apache/skywalking/apm/agent/test/tools/TracingSegmentRunner.java @@ -55,7 +55,7 @@ protected Object createTest() throws Exception { @Override protected Statement withAfters(FrameworkMethod method, Object target, final Statement statement) { - return new Statement() { + Statement st = new Statement() { @Override public void evaluate() throws Throwable { if (field != null) { @@ -89,5 +89,7 @@ public void afterFinished(IgnoredTracerContext tracerContext) { } } }; + + return super.withAfters(method, target, st); } } diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-micrometer-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/micrometer/MicrometerContextSnapshotThreadLocalAccessorInterceptorTest.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-micrometer-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/micrometer/MicrometerContextSnapshotThreadLocalAccessorInterceptorTest.java index 3e3f66c844..258808f8f1 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-micrometer-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/micrometer/MicrometerContextSnapshotThreadLocalAccessorInterceptorTest.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-micrometer-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/micrometer/MicrometerContextSnapshotThreadLocalAccessorInterceptorTest.java @@ -92,8 +92,6 @@ public void clear() { @AfterClass public static void clearAfterAll() { // test from threadlocalaccessor test x 2 TODO: I have no idea what is going on - ContextManager.stopSpan(); - ContextManager.stopSpan(); assertThat(ContextManager.isActive(), is(false)); } @@ -103,6 +101,7 @@ public void testServiceFromPlugin() { PluginBootService.class); Assert.assertNotNull(service); + ContextManager.stopSpan(); } @Test @@ -110,6 +109,7 @@ public void testServiceOverrideFromPlugin() { ContextManagerExtendService service = ServiceManager.INSTANCE.findService(ContextManagerExtendService.class); Assert.assertTrue(service instanceof ContextManagerExtendOverrideService); + ContextManager.stopSpan(); } @Test