Skip to content

Commit 5c40335

Browse files
test(debugger): synchronous probe status generation [backport #6927 to 1.19] (#6932)
Backport of #6927 to 1.19 We make the probe status log message generation synchronous to prevent race conditions in tests that might result in flakiness. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that. --------- Co-authored-by: Emmett Butler <[email protected]>
1 parent eb4f6c5 commit 5c40335

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tests/debugging/mocking.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ def collector(self):
153153
def probe_status_logger(self):
154154
return self._probe_registry.logger
155155

156+
def log_probe_status(self):
157+
self._probe_registry.log_probes_status()
158+
156159
def assert_no_snapshots(self):
157160
assert len(self.test_queue) == 0
158161

tests/debugging/test_debugger.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def test_debugger_line_probe_on_wrapped_function(stuff):
594594
def test_probe_status_logging(remote_config_worker):
595595
assert remoteconfig_poller.status == ServiceStatus.STOPPED
596596

597-
with rcm_endpoint(), debugger(diagnostics_interval=0.2, enabled=True) as d:
597+
with rcm_endpoint(), debugger(diagnostics_interval=float("inf"), enabled=True) as d:
598598
d.add_probes(
599599
create_snapshot_line_probe(
600600
probe_id="line-probe-ok",
@@ -617,15 +617,17 @@ def count_status(queue):
617617

618618
logger.wait(lambda q: count_status(q) == {"INSTALLED": 1, "RECEIVED": 2, "ERROR": 1})
619619

620+
d.log_probe_status()
620621
logger.wait(lambda q: count_status(q) == {"INSTALLED": 2, "RECEIVED": 2, "ERROR": 2})
621622

623+
d.log_probe_status()
622624
logger.wait(lambda q: count_status(q) == {"INSTALLED": 3, "RECEIVED": 2, "ERROR": 3})
623625

624626

625627
def test_probe_status_logging_reemit_on_modify(remote_config_worker):
626628
assert remoteconfig_poller.status == ServiceStatus.STOPPED
627629

628-
with rcm_endpoint(), debugger(diagnostics_interval=0.2, enabled=True) as d:
630+
with rcm_endpoint(), debugger(diagnostics_interval=float("inf"), enabled=True) as d:
629631
d.add_probes(
630632
create_snapshot_line_probe(
631633
version=1,
@@ -662,6 +664,7 @@ def versions(queue, status):
662664
assert versions(queue, "INSTALLED") == [1, 2]
663665
assert versions(queue, "RECEIVED") == [1]
664666

667+
d.log_probe_status()
665668
logger.wait(lambda q: count_status(q) == {"INSTALLED": 3, "RECEIVED": 1})
666669
assert versions(queue, "INSTALLED") == [1, 2, 2]
667670

0 commit comments

Comments
 (0)