Skip to content

Commit 154c151

Browse files
authored
tests(debugging): make RCM data flow synchronous (#6839)
We ensure that a worker thread is not spawned so that we can reliably trigger the RCM data flow manually in tests and remove any potential race conditions with a background worker thread. ## 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 - [ ] Title is accurate. - [ ] No unnecessary changes are introduced. - [ ] Description motivates each change. - [ ] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Testing strategy adequately addresses listed risk(s). - [ ] Change is maintainable (easy to change, telemetry, documentation). - [ ] Release note makes sense to a user of the library. - [ ] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [ ] 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) - [ ] 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`. - [ ] This PR doesn't touch any of that.
1 parent bb8f196 commit 154c151

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tests/debugging/probe/test_remoteconfig.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ def remove_probes(self, *probe_ids):
4141
pass
4242

4343

44+
class SyncProbeRCAdapter(ProbeRCAdapter):
45+
def __init__(self, *args, **kwargs):
46+
super(SyncProbeRCAdapter, self).__init__(*args, **kwargs)
47+
# Prevent the worker thread from starting. We call methods manually.
48+
self._subscriber.is_running = True
49+
50+
4451
def config_metadata(config_id=None):
4552
if config_id is None:
4653
config_id = uuid4()
@@ -126,7 +133,7 @@ def callback(e, ps, *args, **kwargs):
126133
]
127134
)
128135

129-
adapter = ProbeRCAdapter(None, callback, status_logger=None)
136+
adapter = SyncProbeRCAdapter(None, callback, status_logger=None)
130137
remoteconfig_poller.register("TEST", adapter, skip_enabled=True)
131138
adapter.append_and_publish({"test": random.randint(0, 11111111)}, "", config_metadata())
132139
remoteconfig_poller._poll_data()
@@ -143,7 +150,7 @@ def cb(e, ps):
143150
old_interval = di_config.diagnostics_interval
144151
di_config.diagnostics_interval = 0.5
145152
try:
146-
adapter = ProbeRCAdapter(None, cb, status_logger=None)
153+
adapter = SyncProbeRCAdapter(None, cb, status_logger=None)
147154
# Wait to allow the next call to the adapter to generate a status event
148155
remoteconfig_poller.register("TEST", adapter, skip_enabled=True)
149156
adapter.append_and_publish(
@@ -190,7 +197,7 @@ def cb(e, ps):
190197
old_interval = di_config.diagnostics_interval
191198
di_config.diagnostics_interval = float("inf")
192199
try:
193-
adapter = ProbeRCAdapter(None, cb, status_logger=None)
200+
adapter = SyncProbeRCAdapter(None, cb, status_logger=None)
194201
remoteconfig_poller.register("TEST", adapter, skip_enabled=True)
195202
adapter.append(
196203
{
@@ -295,7 +302,7 @@ def callback(e, ps, *args, **kwargs):
295302
old_interval = di_config.diagnostics_interval
296303
di_config.diagnostics_interval = float("inf")
297304
try:
298-
adapter = ProbeRCAdapter(None, callback, status_logger=None)
305+
adapter = SyncProbeRCAdapter(None, callback, status_logger=None)
299306
remoteconfig_poller.register("TEST2", adapter, skip_enabled=True)
300307
adapter.append_and_publish({"test": 2}, "", metadata)
301308
remoteconfig_poller._poll_data()
@@ -347,7 +354,7 @@ def cb(e, ps):
347354
old_interval = di_config.diagnostics_interval
348355
di_config.diagnostics_interval = float("inf")
349356
try:
350-
adapter = ProbeRCAdapter(None, cb, status_logger=mock.Mock())
357+
adapter = SyncProbeRCAdapter(None, cb, status_logger=mock.Mock())
351358
# Wait to allow the next call to the adapter to generate a status event
352359
remoteconfig_poller.register("TEST", adapter, skip_enabled=True)
353360
adapter.append_and_publish(
@@ -540,7 +547,7 @@ def cb(e, ps):
540547
old_interval = di_config.diagnostics_interval
541548
di_config.diagnostics_interval = float("inf")
542549
try:
543-
adapter = ProbeRCAdapter(None, cb, None)
550+
adapter = SyncProbeRCAdapter(None, cb, None)
544551
# Wait to allow the next call to the adapter to generate a status event
545552
remoteconfig_poller.register("TEST", adapter, skip_enabled=True)
546553

@@ -589,7 +596,7 @@ def cb(e, ps):
589596
di_config.diagnostics_interval = float("inf")
590597
try:
591598
status_logger = mock.Mock()
592-
adapter = ProbeRCAdapter(None, cb, status_logger=status_logger)
599+
adapter = SyncProbeRCAdapter(None, cb, status_logger=status_logger)
593600
# Wait to allow the next call to the adapter to generate a status event
594601
remoteconfig_poller.register("TEST", adapter, skip_enabled=True)
595602

0 commit comments

Comments
 (0)