Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions tests/parametric/test_crashtracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_report_crash(self, test_agent, test_library):
test_library.crash()

event = test_agent.wait_for_telemetry_event("logs", wait_loops=400)
assert self.is_crash_report(test_library, event)
self.assert_crash_report(test_library, event)

@pytest.mark.parametrize("library_env", [{"DD_CRASHTRACKING_ENABLED": "false"}])
def test_disable_crashtracking(self, test_agent, test_library):
Expand All @@ -28,7 +28,8 @@ def test_disable_crashtracking(self, test_agent, test_library):
event = json.loads(base64.b64decode(req["body"]))

if event["request_type"] == "logs":
assert self.is_crash_report(test_library, event) is False
with pytest.raises(AssertionError):
self.assert_crash_report(test_library, event)

@bug(library="java", reason="APMLP-302")
@pytest.mark.parametrize("library_env", [{"DD_CRASHTRACKING_ENABLED": "true"}])
Expand All @@ -43,15 +44,11 @@ def test_telemetry_timeout(self, test_agent, test_library, apm_test_server):
finally:
test_agent.set_trace_delay(0)

def is_crash_report(self, test_library, event) -> bool:
if not isinstance(event.get("payload"), list):
return False
if not event["payload"]:
return False
if not isinstance(event["payload"][0], dict):
return False
if "tags" not in event["payload"][0]:
return False
def assert_crash_report(self, test_library, event):
assert isinstance(event.get("payload"), list), event.get("payload")
assert event["payload"], event["payload"]
assert isinstance(event["payload"][0], dict), event["payload"][0]
assert "tags" in event["payload"][0]

tags = event["payload"][0]["tags"]
print("tags: ", tags)
Expand All @@ -62,6 +59,7 @@ def is_crash_report(self, test_library, event) -> bool:
# Most client libraries are using libdatadog so tesing signum tag would work,
# but Java isn't so we end up with testing for severity tag.
if test_library.lang == "java":
return "severity" in tags_dict and tags_dict["severity"] == "crash"

return "signum" in tags_dict
assert "severity" in tags_dict and tags_dict["severity"] == "crash", tags_dict
else:
# According to the RFC, si_signo should be set to 11 for SIGSEGV
assert "signum" in tags_dict or ("si_signo" in tags_dict and tags_dict["si_signo"] == "11"), tags_dict
Loading