Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEBUG-3180 enable Ruby dynamic instrumentation tests #3531

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,21 @@ tests/:
Test_Events: v0.54.2
debugger/:
test_debugger_exception_replay.py:
Test_Debugger_Exception_Replay: missing_feature (feature not implented)
Test_Debugger_Exception_Replay: missing_feature (feature not implemented)
test_debugger_expression_language.py:
Test_Debugger_Expression_Language: missing_feature (feature not implented)
Test_Debugger_Expression_Language: missing_feature (feature not implemented)
test_debugger_pii.py:
Test_Debugger_PII_Redaction: missing_feature (feature not implented)
Test_Debugger_PII_Redaction:
"*": irrelevant
rails70: v2.8.0
test_debugger_probe_snapshot.py:
Test_Debugger_Probe_Snaphots: missing_feature (feature not implented)
Test_Debugger_Probe_Snaphots:
"*": irrelevant
rails70: v2.8.0
test_debugger_probe_status.py:
Test_Debugger_Probe_Statuses: missing_feature (feature not implented)
Test_Debugger_Probe_Statuses:
"*": irrelevant
rails70: v2.8.0
integrations/:
crossed_integrations/:
test_kafka.py:
Expand Down
12 changes: 8 additions & 4 deletions tests/debugger/test_debugger_pii.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
class Test_Debugger_PII_Redaction(debugger._Base_Debugger_Test):
############ setup ############
def _setup(self, line_probe=False):
self.initialize_weblog_remote_config()

if line_probe:
probes = debugger.read_probes("pii_line")
else:
Expand All @@ -141,7 +143,8 @@ def _validate_pii_keyword_redaction(self, should_redact_field_names, line_probe)
not_found = list(set(should_redact_field_names))

for probe_id in self.probe_ids:
snapshot = self.probe_snapshots[probe_id][0]["debugger"]["snapshot"]
base = self.probe_snapshots[probe_id][0]
snapshot = base.get("debugger", {}).get("snapshot") or base["debugger.snapshot"]

for field_name in should_redact_field_names:
if line_probe:
Expand Down Expand Up @@ -176,7 +179,8 @@ def _validate_pii_type_redaction(self, should_redact_types, line_probe):
not_redacted = []

for probe_id in self.probe_ids:
snapshot = self.probe_snapshots[probe_id][0]["debugger"]["snapshot"]
base = self.probe_snapshots[probe_id][0]
snapshot = base.get("debugger", {}).get("snapshot") or base["debugger.snapshot"]

for type_name in should_redact_types:
if line_probe:
Expand Down Expand Up @@ -215,8 +219,8 @@ def setup_pii_redaction_line_full(self):
@missing_feature(
context.library != "ruby", reason="Ruby DI does not provide the functionality required for the test."
)
def pii_redaction_line_full(self):
self._assert(REDACTED_KEYS, REDACTED_TYPES)
def test_pii_redaction_line_full(self):
self._assert(REDACTED_KEYS, REDACTED_TYPES, line_probe=True)

############ old versions ############
def filter(keys_to_filter):
Expand Down
7 changes: 5 additions & 2 deletions tests/debugger/test_debugger_probe_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

import tests.debugger.utils as debugger

from utils import scenarios, features, bug, missing_feature, context
from utils import scenarios, features, bug, missing_feature, context, irrelevant


@features.debugger
@scenarios.debugger_probes_snapshot
class Test_Debugger_Probe_Snaphots(debugger._Base_Debugger_Test):
############ setup ############
def _setup(self, probes_name: str, request_path: str):
self.initialize_weblog_remote_config()

### prepare probes
probes = debugger.read_probes(probes_name)
self.set_probes(probes)
Expand Down Expand Up @@ -55,6 +57,7 @@ def setup_span_method_probe_snaphots(self):
self._setup("probe_snapshot_span_method", "/debugger/span")

@bug(library="python", reason="DEBUG-2708, DEBUG-2709")
@missing_feature(context.library == "ruby", reason="Not yet implemented")
def test_span_method_probe_snaphots(self):
self._assert()
self._validate_spans()
Expand Down Expand Up @@ -82,7 +85,7 @@ def test_log_line_probe_snaphots(self):
def setup_span_decoration_line_probe_snaphots(self):
self._setup("probe_snapshot_span_decoration_line", "/debugger/span-decoration/asd/1")

@missing_feature(context.library == "ruby", reason="Not yet implemented")
@irrelevant(context.library == "ruby", reason="Not yet implemented")
def test_span_decoration_line_probe_snaphots(self):
self._assert()
self._validate_spans()
Expand Down
5 changes: 4 additions & 1 deletion tests/debugger/test_debugger_probe_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import tests.debugger.utils as debugger

from utils import scenarios, features, bug, missing_feature, context
from utils import scenarios, features, bug, missing_feature, context, irrelevant


@features.debugger
Expand All @@ -14,11 +14,14 @@ class Test_Debugger_Probe_Statuses(debugger._Base_Debugger_Test):

############ setup ############
def _setup(self, probes_name: str):
self.initialize_weblog_remote_config()

### prepare probes
probes = debugger.read_probes(probes_name)
self.set_probes(probes)

### set expected
self.expected_diagnostics = {}
for probe in self.probe_definitions:
if probe["id"].endswith("installed"):
self.expected_diagnostics[probe["id"]] = "INSTALLED"
Expand Down
9 changes: 9 additions & 0 deletions tests/debugger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class _Base_Debugger_Test:
rc_state = None
weblog_responses = []

def initialize_weblog_remote_config(self):
if self.get_tracer()["language"] == "ruby":
# Ruby tracer initializes remote configuration client from
# middleware that is only invoked during request processing.
# Therefore, we need to issue a request to the application for
# remote config to start.
response = weblog.get("/debugger/init")
assert response.status_code == 200
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I also miss that point. setup function must never fail. If you want to add any assertion, it must be done inside test functions.

def setup_stuff:
    self.init_response = weblog.get("/debugger/init")

def test_stuff:
    assert self.init_response.status_code == 200

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must setup never fail?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Test functions" are instrumented by the framework to offer a friendly output on failure (logs, some variables values on assert.

setup functions are executed during the lifespan of the tested infra, but they are not "test functions". If they fails, you'll have a basic stack trace painful to understand


###### set #####
def set_probes(self, probes):
def _enrich_probes(probes):
Expand Down
Loading