Skip to content

Commit 2953144

Browse files
committed
test: cap helper get_service_info timeout in test_get_info_suppressed_by_question_history (~3.0s → ~1.85s)
The helper thread calls `zc.get_service_info` with the default 3000ms timeout. Every query in this test is suppressed by the seeded question history, so no answer ever arrives — the helper sits at the timeout. The three phase waits in the main thread sum to ~2.06s, so capping the helper at 1500ms is safe and lets the test finish in the phase-wait budget instead of the helper budget. No production change.
1 parent 6db1f91 commit 2953144

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎tests/services/test_info.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ def mock_incoming_msg(records: Iterable[r.DNSRecord]) -> r.DNSIncoming:
430430

431431
return r.DNSIncoming(generated.packets()[0])
432432

433-
def get_service_info_helper(zc, type, name):
433+
def get_service_info_helper(zc, type, name, timeout):
434434
nonlocal service_info
435-
service_info = zc.get_service_info(type, name)
435+
service_info = zc.get_service_info(type, name, timeout)
436436
service_info_event.set()
437437

438438
try:
@@ -453,9 +453,14 @@ def get_service_info_helper(zc, type, name):
453453
for question in seed_history_questions:
454454
zc.question_history.add_question_at_time(question, far_future, set())
455455

456+
# No answers ever come back (all queries are suppressed),
457+
# so cap the helper at the worst-case sum of the three
458+
# phase waits below plus margin instead of the 3000ms
459+
# default. Phase 3 waits ~1.6s (the 999ms QM gap plus
460+
# jitter and 500ms buffer); 1500ms covers it.
456461
helper_thread = threading.Thread(
457462
target=get_service_info_helper,
458-
args=(zc, service_type, service_name),
463+
args=(zc, service_type, service_name, 1500),
459464
)
460465
helper_thread.start()
461466
wait_time = (const._LISTENER_TIME + info._AVOID_SYNC_DELAY_RANDOM_INTERVAL[1] + 500) / 1000

0 commit comments

Comments
 (0)