Skip to content

Commit c588f9c

Browse files
P403n1x87majorgreys
authored andcommitted
test(debugging): remove flakiness in uploader and encoder tests (#6864)
We remove some residual flakiness in the uploader and encoding tests by making more operations synchronous in tests to remove potential race conditions. ## 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.
1 parent 5d94749 commit c588f9c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

tests/debugging/test_debugger.py

Lines changed: 7 additions & 7 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=0, enabled=True) as d:
598598
d.add_probes(
599599
create_snapshot_line_probe(
600600
probe_id="line-probe-ok",
@@ -625,7 +625,7 @@ def count_status(queue):
625625
def test_probe_status_logging_reemit_on_modify(remote_config_worker):
626626
assert remoteconfig_poller.status == ServiceStatus.STOPPED
627627

628-
with rcm_endpoint(), debugger(diagnostics_interval=0.2, enabled=True) as d:
628+
with rcm_endpoint(), debugger(diagnostics_interval=0, enabled=True) as d:
629629
d.add_probes(
630630
create_snapshot_line_probe(
631631
version=1,
@@ -670,7 +670,7 @@ def versions(queue, status):
670670
def test_debugger_function_probe_duration(duration):
671671
from tests.submod.stuff import durationstuff
672672

673-
with debugger(poll_interval=0.1) as d:
673+
with debugger(poll_interval=0) as d:
674674
d.add_probes(
675675
create_snapshot_function_probe(
676676
probe_id="duration-probe",
@@ -688,7 +688,7 @@ def test_debugger_function_probe_duration(duration):
688688
def test_debugger_condition_eval_then_rate_limit():
689689
from tests.submod.stuff import Stuff
690690

691-
with debugger(upload_flush_interval=0.1) as d:
691+
with debugger(upload_flush_interval=float("inf")) as d:
692692
d.add_probes(
693693
create_snapshot_line_probe(
694694
probe_id="foo",
@@ -718,7 +718,7 @@ def test_debugger_condition_eval_then_rate_limit():
718718
def test_debugger_condition_eval_error_get_reported_once():
719719
from tests.submod.stuff import Stuff
720720

721-
with debugger(upload_flush_interval=0.1) as d:
721+
with debugger(upload_flush_interval=float("inf")) as d:
722722
d.add_probes(
723723
create_snapshot_line_probe(
724724
probe_id="foo",
@@ -846,7 +846,7 @@ def __init__(self, age, name):
846846
def test_debugger_log_live_probe_generate_messages():
847847
from tests.submod.stuff import Stuff
848848

849-
with debugger(upload_flush_interval=0.1) as d:
849+
with debugger(upload_flush_interval=float("inf")) as d:
850850
d.add_probes(
851851
create_log_line_probe(
852852
probe_id="foo",
@@ -989,7 +989,7 @@ def child():
989989
def test_debugger_modified_probe():
990990
from tests.submod.stuff import Stuff
991991

992-
with debugger(upload_flush_interval=0.1) as d:
992+
with debugger(upload_flush_interval=float("inf")) as d:
993993
d.add_probes(
994994
create_log_line_probe(
995995
probe_id="foo",

tests/debugging/test_uploader.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def __init__(self, size=1 << 10, interval=1):
2929
)
3030

3131
def on_full(self, item, encoded):
32-
self.upload()
32+
self.periodic()
3333

3434

3535
def test_uploader_batching():
36-
with ActiveBatchJsonEncoder(interval=0.1) as uploader:
36+
with ActiveBatchJsonEncoder(interval=float("inf")) as uploader:
3737
for _ in range(5):
3838
uploader._encoder.put("hello")
3939
uploader._encoder.put("world")
40-
uploader.awake()
40+
uploader.periodic()
4141

4242
for _ in range(5):
4343
assert uploader.queue.get(timeout=1) == "[hello,world]", "iteration %d" % _
@@ -46,7 +46,7 @@ def test_uploader_batching():
4646
@pytest.mark.xfail(condition=PY2, reason="This test is flaky on Python 2")
4747
def test_uploader_full_buffer():
4848
size = 1 << 8
49-
with ActiveBatchJsonEncoder(size=size, interval=0.1) as uploader:
49+
with ActiveBatchJsonEncoder(size=size, interval=float("inf")) as uploader:
5050
item = "hello" * 10
5151
n = size // len(item)
5252
assert n
@@ -60,5 +60,5 @@ def test_uploader_full_buffer():
6060
assert uploader.queue.qsize() == 0
6161

6262
# wakeup to mimic next interval
63-
uploader.awake()
63+
uploader.periodic()
6464
assert uploader.queue.qsize() == 0

0 commit comments

Comments
 (0)