Skip to content

Commit 43ffd7e

Browse files
update instrumentation test fixtures
1 parent 407e5c7 commit 43ffd7e

File tree

11 files changed

+534
-7
lines changed

11 files changed

+534
-7
lines changed

dd-java-agent/instrumentation/junit-4.10/src/main/java/datadog/trace/instrumentation/junit4/JUnit4BeforeAfterInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static AgentScope startCallSpan(@Advice.Argument(0) final FrameworkMethod
5757
return AgentTracer.activateSpan(span);
5858
}
5959

60-
@Advice.OnMethodExit(suppress = Throwable.class)
60+
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
6161
public static void finishCallSpan(@Advice.Enter final AgentScope scope) {
6262
AgentSpan span = scope.span();
6363
scope.close();

dd-java-agent/instrumentation/junit-4.10/src/test/groovy/JUnit4Test.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import org.example.TestSkipped
2020
import org.example.TestSkippedClass
2121
import org.example.TestSucceed
2222
import org.example.TestSucceedAndSkipped
23+
import org.example.TestSucceedBeforeAfter
24+
import org.example.TestSucceedBeforeClassAfterClass
2325
import org.example.TestSucceedExpectedException
2426
import org.example.TestSucceedKotlin
2527
import org.example.TestSucceedLegacy
@@ -54,6 +56,8 @@ class JUnit4Test extends CiVisibilityInstrumentationTest {
5456
"test-success-and-failure" | [TestFailedAndSucceed] | 4
5557
"test-suite-teardown-failure" | [TestFailedSuiteTearDown] | 1
5658
"test-suite-setup-failure" | [TestFailedSuiteSetup] | 1
59+
"test-succeed-before-after" | [TestSucceedBeforeAfter] | 2
60+
"test-succeed-before-class-after-class" | [TestSucceedBeforeClassAfterClass] | 2
5761
"test-assumption-failure" | [TestAssumption] | 2
5862
"test-categories-are-included-in-spans" | [TestSucceedWithCategories] | 2
5963
"test-assumption-failure-during-suite-setup" | [TestFailedSuiteSetUpAssumption] | 2
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.example;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.junit.After;
6+
import org.junit.Before;
7+
import org.junit.Test;
8+
9+
public class TestSucceedBeforeAfter {
10+
@Before
11+
public void testSetup() {}
12+
13+
@After
14+
public void testTeardown() {}
15+
16+
@Test
17+
public void testSucceed() {
18+
assertTrue(true);
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.example;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.junit.AfterClass;
6+
import org.junit.BeforeClass;
7+
import org.junit.Test;
8+
9+
public class TestSucceedBeforeClassAfterClass {
10+
@BeforeClass
11+
public static void classSetup() {}
12+
13+
@AfterClass
14+
public static void classTeardown() {}
15+
16+
@Test
17+
public void testSucceed() {
18+
assertTrue(true);
19+
}
20+
}

dd-java-agent/instrumentation/junit-4.10/src/test/resources/test-assumption-failure-during-suite-setup/events.ftl

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
"duration" : ${content_duration},
1111
"error" : 0,
1212
"metrics" : {
13+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count},
1314
"process_id" : ${content_metrics_process_id},
1415
"_dd.profiling.enabled" : 0,
1516
"_dd.trace_span_attribute_schema" : 0
1617
},
1718
"meta" : {
19+
"_dd.p.tid" : ${content_meta__dd_p_tid},
1820
"test.type" : "test",
1921
"_dd.tracer_host" : ${content_meta__dd_tracer_host},
2022
"test.status" : "skip",
@@ -44,8 +46,11 @@
4446
"start" : ${content_start_2},
4547
"duration" : ${content_duration_2},
4648
"error" : 0,
47-
"metrics" : { },
49+
"metrics" : {
50+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}
51+
},
4852
"meta" : {
53+
"_dd.p.tid" : ${content_meta__dd_p_tid_2},
4954
"test.type" : "test",
5055
"test.module" : "junit-4.10",
5156
"test.status" : "skip",
@@ -72,8 +77,13 @@
7277
"start" : ${content_start_3},
7378
"duration" : ${content_duration_3},
7479
"error" : 0,
75-
"metrics" : { },
80+
"metrics" : {
81+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3},
82+
"test.source.end" : 19,
83+
"test.source.start" : 11
84+
},
7685
"meta" : {
86+
"_dd.p.tid" : ${content_meta__dd_p_tid_3},
7787
"test.type" : "test",
7888
"test.source.file" : "dummy_source_path",
7989
"test.module" : "junit-4.10",
@@ -82,6 +92,7 @@
8292
"test_session.name" : "session-name",
8393
"env" : "none",
8494
"dummy_ci_tag" : "dummy_ci_tag_value",
95+
"test.codeowners" : "[\"owner1\",\"owner2\"]",
8596
"library_version" : ${content_meta_library_version},
8697
"component" : "junit",
8798
"span.kind" : "test_suite_end",
@@ -110,6 +121,7 @@
110121
"process_id" : ${content_metrics_process_id},
111122
"_dd.profiling.enabled" : 0,
112123
"_dd.trace_span_attribute_schema" : 0,
124+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4},
113125
"test.source.end" : 18,
114126
"test.source.start" : 12
115127
},
@@ -137,4 +149,25 @@
137149
"test.framework" : "junit4"
138150
}
139151
}
152+
}, {
153+
"type" : "span",
154+
"version" : 1,
155+
"content" : {
156+
"trace_id" : ${content_test_session_id},
157+
"span_id" : ${content_span_id_2},
158+
"parent_id" : ${content_test_suite_id},
159+
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
160+
"name" : "suiteSetup",
161+
"resource" : "suiteSetup",
162+
"start" : ${content_start_5},
163+
"duration" : ${content_duration_5},
164+
"error" : 0,
165+
"metrics" : { },
166+
"meta" : {
167+
"_dd.p.tid" : ${content_meta__dd_p_tid_4},
168+
"test.callback" : "BeforeClass",
169+
"library_version" : ${content_meta_library_version},
170+
"env" : "none"
171+
}
172+
}
140173
} ]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[ ]
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
[ {
2+
"type" : "test_session_end",
3+
"version" : 1,
4+
"content" : {
5+
"test_session_id" : ${content_test_session_id},
6+
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
7+
"name" : "junit.test_session",
8+
"resource" : "junit-4.10",
9+
"start" : ${content_start},
10+
"duration" : ${content_duration},
11+
"error" : 0,
12+
"metrics" : {
13+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count},
14+
"process_id" : ${content_metrics_process_id},
15+
"_dd.profiling.enabled" : 0,
16+
"_dd.trace_span_attribute_schema" : 0
17+
},
18+
"meta" : {
19+
"_dd.p.tid" : ${content_meta__dd_p_tid},
20+
"test.type" : "test",
21+
"_dd.tracer_host" : ${content_meta__dd_tracer_host},
22+
"test.status" : "pass",
23+
"test_session.name" : "session-name",
24+
"language" : "jvm",
25+
"env" : "none",
26+
"dummy_ci_tag" : "dummy_ci_tag_value",
27+
"library_version" : ${content_meta_library_version},
28+
"component" : "junit",
29+
"_dd.profiling.ctx" : "test",
30+
"span.kind" : "test_session_end",
31+
"runtime-id" : ${content_meta_runtime_id},
32+
"test.command" : "junit-4.10",
33+
"test.framework_version" : ${content_meta_test_framework_version},
34+
"test.framework" : "junit4"
35+
}
36+
}
37+
}, {
38+
"type" : "test_module_end",
39+
"version" : 1,
40+
"content" : {
41+
"test_session_id" : ${content_test_session_id},
42+
"test_module_id" : ${content_test_module_id},
43+
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
44+
"name" : "junit.test_module",
45+
"resource" : "junit-4.10",
46+
"start" : ${content_start_2},
47+
"duration" : ${content_duration_2},
48+
"error" : 0,
49+
"metrics" : {
50+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2}
51+
},
52+
"meta" : {
53+
"_dd.p.tid" : ${content_meta__dd_p_tid_2},
54+
"test.type" : "test",
55+
"test.module" : "junit-4.10",
56+
"test.status" : "pass",
57+
"test_session.name" : "session-name",
58+
"env" : "none",
59+
"dummy_ci_tag" : "dummy_ci_tag_value",
60+
"library_version" : ${content_meta_library_version},
61+
"component" : "junit",
62+
"span.kind" : "test_module_end",
63+
"test.framework_version" : ${content_meta_test_framework_version},
64+
"test.framework" : "junit4"
65+
}
66+
}
67+
}, {
68+
"type" : "test_suite_end",
69+
"version" : 1,
70+
"content" : {
71+
"test_session_id" : ${content_test_session_id},
72+
"test_module_id" : ${content_test_module_id},
73+
"test_suite_id" : ${content_test_suite_id},
74+
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
75+
"name" : "junit.test_suite",
76+
"resource" : "org.example.TestSucceedBeforeAfter",
77+
"start" : ${content_start_3},
78+
"duration" : ${content_duration_3},
79+
"error" : 0,
80+
"metrics" : {
81+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3},
82+
"test.source.end" : 19,
83+
"test.source.start" : 11
84+
},
85+
"meta" : {
86+
"_dd.p.tid" : ${content_meta__dd_p_tid_3},
87+
"test.type" : "test",
88+
"test.source.file" : "dummy_source_path",
89+
"test.module" : "junit-4.10",
90+
"test.status" : "pass",
91+
"test_session.name" : "session-name",
92+
"env" : "none",
93+
"dummy_ci_tag" : "dummy_ci_tag_value",
94+
"test.codeowners" : "[\"owner1\",\"owner2\"]",
95+
"library_version" : ${content_meta_library_version},
96+
"component" : "junit",
97+
"span.kind" : "test_suite_end",
98+
"test.suite" : "org.example.TestSucceedBeforeAfter",
99+
"test.framework_version" : ${content_meta_test_framework_version},
100+
"test.framework" : "junit4"
101+
}
102+
}
103+
}, {
104+
"type" : "test",
105+
"version" : 2,
106+
"content" : {
107+
"trace_id" : ${content_trace_id},
108+
"span_id" : ${content_span_id},
109+
"parent_id" : ${content_parent_id},
110+
"test_session_id" : ${content_test_session_id},
111+
"test_module_id" : ${content_test_module_id},
112+
"test_suite_id" : ${content_test_suite_id},
113+
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
114+
"name" : "junit.test",
115+
"resource" : "org.example.TestSucceedBeforeAfter.testSucceed",
116+
"start" : ${content_start_4},
117+
"duration" : ${content_duration_4},
118+
"error" : 0,
119+
"metrics" : {
120+
"process_id" : ${content_metrics_process_id},
121+
"_dd.profiling.enabled" : 0,
122+
"_dd.trace_span_attribute_schema" : 0,
123+
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4},
124+
"test.source.end" : 18,
125+
"test.source.start" : 12
126+
},
127+
"meta" : {
128+
"_dd.tracer_host" : ${content_meta__dd_tracer_host},
129+
"test.source.file" : "dummy_source_path",
130+
"test.source.method" : "testSucceed()V",
131+
"test.module" : "junit-4.10",
132+
"test.status" : "pass",
133+
"language" : "jvm",
134+
"test.codeowners" : "[\"owner1\",\"owner2\"]",
135+
"library_version" : ${content_meta_library_version},
136+
"test.name" : "testSucceed",
137+
"span.kind" : "test",
138+
"test.suite" : "org.example.TestSucceedBeforeAfter",
139+
"runtime-id" : ${content_meta_runtime_id},
140+
"test.type" : "test",
141+
"test_session.name" : "session-name",
142+
"env" : "none",
143+
"dummy_ci_tag" : "dummy_ci_tag_value",
144+
"component" : "junit",
145+
"_dd.profiling.ctx" : "test",
146+
"test.framework_version" : ${content_meta_test_framework_version},
147+
"test.framework" : "junit4"
148+
}
149+
}
150+
}, {
151+
"type" : "span",
152+
"version" : 1,
153+
"content" : {
154+
"trace_id" : ${content_trace_id},
155+
"span_id" : ${content_span_id_2},
156+
"parent_id" : ${content_span_id},
157+
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
158+
"name" : "testSetup",
159+
"resource" : "testSetup",
160+
"start" : ${content_start_5},
161+
"duration" : ${content_duration_5},
162+
"error" : 0,
163+
"metrics" : { },
164+
"meta" : {
165+
"test.callback" : "Before",
166+
"library_version" : ${content_meta_library_version},
167+
"env" : "none"
168+
}
169+
}
170+
}, {
171+
"type" : "span",
172+
"version" : 1,
173+
"content" : {
174+
"trace_id" : ${content_trace_id},
175+
"span_id" : ${content_span_id_3},
176+
"parent_id" : ${content_span_id},
177+
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
178+
"name" : "testTeardown",
179+
"resource" : "testTeardown",
180+
"start" : ${content_start_6},
181+
"duration" : ${content_duration_6},
182+
"error" : 0,
183+
"metrics" : { },
184+
"meta" : {
185+
"test.callback" : "After",
186+
"library_version" : ${content_meta_library_version},
187+
"env" : "none"
188+
}
189+
}
190+
} ]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[ ]

0 commit comments

Comments
 (0)