test: speed up service-info request tests with quick_request_timing fixture#1709
Merged
Conversation
…ixture `AsyncServiceInfo.async_request` waits `_LISTENER_TIME` (200ms) plus 20-120ms of jitter before firing the first query. On real networks that staggering helps clients avoid synchronized bursts (RFC 6762 §5.2); on loopback it's pure overhead. Tests that only need to see which queries get sent paid the wait every time and had to pad their timeouts to ~500ms to accommodate it. New `quick_request_timing` fixture patches `_LISTENER_TIME=10` and the jitter interval to `(1, 5)`. With the fixture, callers can drop their timeouts and negative-wait windows to ~50-100ms. Speedups: - test_get_info_single: 1.01s → 0.11s - test_info_asking_default_is_asking_qm_questions_after_the_first_qu: 0.77s → 0.30s - test_asking_qu_questions: 0.52s → 0.05s - test_asking_qm_questions: similar, also picks up the fixture for symmetry with test_asking_qu_questions. No production change — both constants were already plain Python module attributes on `_services.info` (not declared in `info.pxd`), so the patches take effect under both the Cython and pure-Python builds.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1709 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 33 33
Lines 3426 3426
Branches 471 471
=======================================
Hits 3418 3418
Misses 5 5
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3 tasks
…UT_MS) The 50ms get_service_info / async_request timeout used by the three tests that opt in to `quick_request_timing` was a bare integer literal. Hoist it to a `QUICK_REQUEST_TIMEOUT_MS` constant in `tests/__init__.py` so the relationship to the fixture (which shortens the initial-query delay to ~15ms) is documented and the value lives in one place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #1707 (slow tests sweep). Bucket B of a 3-PR series (follows #1708).
AsyncServiceInfo.async_requestwaits_LISTENER_TIME(200ms) plus 20-120ms of jitter before firing the first query — RFC 6762 §5.2 spread-out behavior for real networks. On loopback that's pure overhead. Tests that only need to see which queries get sent paid the wait every time and had to pad their timeouts to ~500ms to accommodate it.New
quick_request_timingfixture intests/conftest.pypatches_LISTENER_TIME=10and_AVOID_SYNC_DELAY_RANDOM_INTERVAL=(1, 5). With the fixture, callers can drop their timeouts and negative-wait windows to ~50-100ms.Speedups:
test_get_info_singletest_info_asking_default_is_asking_qm_questions_after_the_first_qutest_asking_qu_questionstest_asking_qm_questions(symmetric — picked up for consistency)No production change — both constants were already plain Python module attributes on
_services.info(not declared ininfo.pxd), so the patches take effect under both the Cython and pure-Python builds.Test plan
tests/suite passes (337 passed, 3 IPv6 skips)