Skip to content

Commit b6e89cd

Browse files
bric3devflow.devflow-routing-intake
andauthored
Indented crashtracking test events (#10996)
chore(crashtracking): Use parsed json for crashatracking event comparison chore(crashtracking): Renmae test files with json extension Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent b8087fd commit b6e89cd

21 files changed

Lines changed: 1662 additions & 23 deletions

dd-java-agent/agent-crashtracking/src/test/java/datadog/crashtracking/CrashUploaderTest.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private Path getResourcePath(String resourceName) throws Exception {
140140
@Test
141141
public void testTelemetryCrashPing() throws Exception {
142142
// Given
143-
final String expected = readFileAsString("golden/telemetry/sample-ping-for-telemetry.txt");
143+
final String expected = readFileAsString("golden/telemetry/sample-ping-for-telemetry.json");
144144
ConfigManager.StoredConfig crashConfig =
145145
new ConfigManager.StoredConfig.Builder(config)
146146
.reportUUID(SAMPLE_UUID)
@@ -176,7 +176,9 @@ public void testTelemetryCrashPing() throws Exception {
176176
assertTrue(tags.contains("runtime_version:"));
177177
assertTrue(tags.contains("runtime_vendor:"));
178178
assertTrue(tags.contains("runtime_name:"));
179-
assertEquals(expected, event.get("payload").get(0).get("message").asText());
179+
assertEquals(
180+
mapper.readTree(expected),
181+
mapper.readTree(event.get("payload").get(0).get("message").asText()));
180182
assertCommonPayload(event);
181183
}
182184

@@ -185,7 +187,7 @@ public void testErrorTrackingCrashPing() throws Exception {
185187
// Given
186188
final ObjectMapper mapper = new ObjectMapper();
187189
final Map<String, ?> expected =
188-
mapper.readValue(readFileAsString("golden/errortracking/sample-ping.txt"), Map.class);
190+
mapper.readValue(readFileAsString("golden/errortracking/sample-ping.json"), Map.class);
189191
// remove ddtags and osinfo if present from the expected (they will be checked apart)
190192
expected.remove("ddtags");
191193
expected.remove("os_info");
@@ -251,14 +253,15 @@ public void testErrorTrackingCrashPing() throws Exception {
251253
@ParameterizedTest
252254
@ValueSource(
253255
strings = {
254-
"sample-crash-for-telemetry.txt",
255-
"sample-crash-for-telemetry-2.txt",
256-
"sample-crash-for-telemetry-3.txt",
257-
"sample_oom.txt"
256+
"sample-crash-for-telemetry.json",
257+
"sample-crash-for-telemetry-2.json",
258+
"sample-crash-for-telemetry-3.json",
259+
"sample_oom.json"
258260
})
259261
public void testTelemetryHappyPath(String log) throws Exception {
260262
// Given
261263
CrashLog expected = CrashLog.fromJson(readFileAsString("golden/telemetry/" + log));
264+
final String inputLog = log.replace(".json", ".txt");
262265
ConfigManager.StoredConfig crashConfig =
263266
new ConfigManager.StoredConfig.Builder(config)
264267
.reportUUID(SAMPLE_UUID)
@@ -268,7 +271,7 @@ public void testTelemetryHappyPath(String log) throws Exception {
268271
// When
269272
uploader = new CrashUploader(config, crashConfig);
270273
server.enqueue(new MockResponse().setResponseCode(200));
271-
uploader.upload(getResourcePath(log));
274+
uploader.upload(getResourcePath(inputLog));
272275

273276
final RecordedRequest recordedRequest = server.takeRequest(5, TimeUnit.SECONDS);
274277

@@ -299,10 +302,10 @@ public void testTelemetryHappyPath(String log) throws Exception {
299302
@ParameterizedTest
300303
@ValueSource(
301304
strings = {
302-
"sample-crash-for-telemetry.txt",
303-
"sample-crash-for-telemetry-2.txt",
304-
"sample-crash-for-telemetry-3.txt",
305-
"sample_oom.txt"
305+
"sample-crash-for-telemetry.json",
306+
"sample-crash-for-telemetry-2.json",
307+
"sample-crash-for-telemetry-3.json",
308+
"sample_oom.json"
306309
})
307310
public void testErrorTrackingHappyPath(String log) throws Exception {
308311
// Given
@@ -312,6 +315,7 @@ public void testErrorTrackingHappyPath(String log) throws Exception {
312315
// remove ddtags and osinfo if present from the expected (they will be checked apart)
313316
expected.remove("ddtags");
314317
expected.remove("os_info");
318+
final String inputLog = log.replace(".json", ".txt");
315319
ConfigManager.StoredConfig crashConfig =
316320
new ConfigManager.StoredConfig.Builder(config)
317321
.reportUUID(SAMPLE_UUID)
@@ -322,7 +326,7 @@ public void testErrorTrackingHappyPath(String log) throws Exception {
322326
// When
323327
uploader = new CrashUploader(config, crashConfig);
324328
server.enqueue(new MockResponse().setResponseCode(200));
325-
uploader.remoteUpload(readFileAsString(log), false, true);
329+
uploader.remoteUpload(readFileAsString(inputLog), false, true);
326330

327331
final RecordedRequest recordedRequest = server.takeRequest(5, TimeUnit.SECONDS);
328332

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"timestamp": "2024-09-20T13:19:06Z",
3+
"ddsource": "crashtracker",
4+
"error": {
5+
"is_crash": true,
6+
"type": "SIGSEGV",
7+
"message": "Process terminated by signal SIGSEGV",
8+
"source_type": "Crashtracking",
9+
"stack": {
10+
"format": "CrashTrackerV1",
11+
"frames": [
12+
{
13+
"function": "__pthread_clockjoin_ex+0x255",
14+
"path": "libpthread.so.0",
15+
"relative_address": "0x9cd5",
16+
"type": "native"
17+
}
18+
]
19+
}
20+
},
21+
"sig_info": {
22+
"si_signo_human_readable": "SIGSEGV",
23+
"si_signo": 11,
24+
"si_code": 0,
25+
"si_code_human_readable": "SI_USER",
26+
"si_pid": 554848,
27+
"si_uid": 1000
28+
},
29+
"experimental": {
30+
"ucontext": {
31+
"RAX": "0x00000000000000ca",
32+
"RBX": "0x00000000000000ca",
33+
"RCX": "0x00007f011ab1ccd7",
34+
"RDX": "0x000000000008ca23",
35+
"RSP": "0x00007ffeabf89710",
36+
"RBP": "0x00007ffeabf897b8",
37+
"RSI": "0x0000000000000000",
38+
"RDI": "0x00007f01192129d0",
39+
"R8": "0x0000000000000000",
40+
"R9": "0x00007f0119212700",
41+
"R10": "0x0000000000000000",
42+
"R11": "0x0000000000000246",
43+
"R12": "0x000000000008ca23",
44+
"R13": "0x00007f01192129d0",
45+
"R14": "0x00007ffeabf89840",
46+
"R15": "0x00007f0119212700",
47+
"RIP": "0x00007f011ab1ccd5",
48+
"EFLAGS": "0x0000000000000246",
49+
"CSGSFS": "0x002b000000000033",
50+
"ERR": "0x0000000000000000",
51+
"TRAPNO": "0x0000000000000000"
52+
}
53+
}
54+
}

dd-java-agent/agent-crashtracking/src/test/resources/golden/errortracking/sample-crash-for-telemetry-2.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"timestamp": "2024-09-25T11:32:03+02:00",
3+
"ddsource": "crashtracker",
4+
"error": {
5+
"is_crash": true,
6+
"type": "OutOfMemory",
7+
"message": "Java heap space",
8+
"thread_name": "JavaThread \"main\"",
9+
"source_type": "Crashtracking",
10+
"stack": {
11+
"format": "CrashTrackerV1",
12+
"frames": [
13+
{
14+
"function": "VMError::report_and_die()+0x468",
15+
"path": "libjvm.dylib",
16+
"relative_address": "0x565d30",
17+
"type": "vm"
18+
},
19+
{
20+
"function": "report_vm_error(char const*, int, char const*, char const*)+0x5c",
21+
"path": "libjvm.dylib",
22+
"relative_address": "0x1941a0",
23+
"type": "vm"
24+
},
25+
{
26+
"function": "report_java_out_of_memory(char const*)+0xfc",
27+
"path": "libjvm.dylib",
28+
"relative_address": "0x1943d8",
29+
"type": "vm"
30+
},
31+
{
32+
"function": "CollectedHeap::common_mem_allocate_noinit(KlassHandle, unsigned long, Thread*)+0x128",
33+
"path": "libjvm.dylib",
34+
"relative_address": "0x70430",
35+
"type": "vm"
36+
},
37+
{
38+
"function": "TypeArrayKlass::allocate_common(int, bool, Thread*)+0xfc",
39+
"path": "libjvm.dylib",
40+
"relative_address": "0x53eba8",
41+
"type": "vm"
42+
},
43+
{
44+
"function": "InterpreterRuntime::newarray(JavaThread*, BasicType, int)+0x48",
45+
"path": "libjvm.dylib",
46+
"relative_address": "0x285b6c",
47+
"type": "vm"
48+
},
49+
{
50+
"function": "datadog.smoketest.crashtracking.CrashtrackingTestApplication.main([Ljava/lang/String;)V",
51+
"line": 105,
52+
"type": "interpreted"
53+
},
54+
{
55+
"function": "~StubRoutines::call_stub",
56+
"type": "stub"
57+
},
58+
{
59+
"function": "JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*)+0x840",
60+
"path": "libjvm.dylib",
61+
"relative_address": "0x28f86c",
62+
"type": "vm"
63+
},
64+
{
65+
"function": "jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*)+0x294",
66+
"path": "libjvm.dylib",
67+
"relative_address": "0x2d3b44",
68+
"type": "vm"
69+
},
70+
{
71+
"function": "jni_CallStaticVoidMethod+0x188",
72+
"path": "libjvm.dylib",
73+
"relative_address": "0x2d7160",
74+
"type": "vm"
75+
},
76+
{
77+
"function": "JavaMain+0xa10",
78+
"path": "java",
79+
"relative_address": "0x6404",
80+
"type": "native"
81+
},
82+
{
83+
"function": "_pthread_start+0x88",
84+
"path": "libsystem_pthread.dylib",
85+
"relative_address": "0x6f94",
86+
"type": "native"
87+
},
88+
{
89+
"function": "thread_start+0x8",
90+
"path": "libsystem_pthread.dylib",
91+
"relative_address": "0x1d34",
92+
"type": "native"
93+
},
94+
{
95+
"function": "datadog.smoketest.crashtracking.CrashtrackingTestApplication.main([Ljava/lang/String;)V",
96+
"line": 105,
97+
"type": "interpreted"
98+
},
99+
{
100+
"function": "~StubRoutines::call_stub",
101+
"type": "stub"
102+
}
103+
]
104+
}
105+
}
106+
}

dd-java-agent/agent-crashtracking/src/test/resources/golden/errortracking/sample-crash-for-telemetry-3.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)