Commit a22d068
committed
test: shave register/shutdown/TC waits on loopback
`async_check_service` paid an inline `random.randint(150, 250)` ms wait
on every `register_service` — RFC 6762 §8.1 thundering-herd avoidance
for real networks, pure overhead on 127.0.0.1. Extracted as a module
constant `_REGISTER_RANDOM_INTERVAL` and patched in the `quick_timing`
fixture to (1, 5)ms alongside the existing _CHECK_TIME / _REGISTER_TIME
/ _UNREGISTER_TIME shaves.
Also:
- `test_shutdown_loop`: drop `.result(1)` → `.result(0.1)` and patch
`_TASK_AWAIT_TIMEOUT` to 0.1s. The 1s waits were `shutdown_loop`'s
outer timeout on a never-completing `asyncio.sleep(5)` — the test only
needs the loop to be stoppable while a task is pending.
- `test_tc_bit_defers_last_response_missing`: patch
`_TC_DELAY_RANDOM_INTERVAL` (400-500ms, RFC 6762 §7.2 TC-bit deferral)
to (10, 20)ms and tighten the cleanup poll loop.
- `test_integration`: wait for the browser's first startup query to
fire (with empty cache) before registering. Previously the test
relied on the register's 150-250ms random wait being longer than the
browser's 20-120ms first-query delay; with the new fast register that
race flipped and the first query started seeing the known PTR via
§7.1 known-answer suppression.
Speedups on loopback (CPython 3.12):
| test | before | after |
| ----------------------------------------------------- | ------ | ----- |
| test_shutdown_loop | 1.16s | 0.26s |
| test_tc_bit_defers_last_response_missing | 0.79s | 0.32s |
| test_async_service_registration_name_conflict | 0.72s | 0.10s |
| test_name_conflicts | 0.50s | 0.10s |
Plus a smaller transparent shave on every other `quick_timing`
register-based test. Full suite: 338 passed, 2 skipped. No production
behavior change — `_REGISTER_RANDOM_INTERVAL` still defaults to the
RFC 6762 §8.1 value on real networks.1 parent 4bae30a commit a22d068
5 files changed
Lines changed: 23 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| |||
561 | 565 | | |
562 | 566 | | |
563 | 567 | | |
564 | | - | |
| 568 | + | |
565 | 569 | | |
566 | 570 | | |
567 | 571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1060 | 1060 | | |
1061 | 1061 | | |
1062 | 1062 | | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
1063 | 1069 | | |
1064 | 1070 | | |
1065 | 1071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
| 634 | + | |
634 | 635 | | |
635 | 636 | | |
636 | 637 | | |
| |||
730 | 731 | | |
731 | 732 | | |
732 | 733 | | |
733 | | - | |
734 | | - | |
| 734 | + | |
| 735 | + | |
735 | 736 | | |
736 | 737 | | |
737 | 738 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
0 commit comments