Commit 76c31a7
committed
test: shave ServiceBrowser first-query delay on loopback
`ServiceBrowser` waits `random.randint(20, 120)` ms before its
first query — RFC 6762 §5.2 thundering-herd avoidance for real
networks, pure overhead on 127.0.0.1. Every browser-using test
pays it, and `ZeroconfServiceTypes.find()` adds it on top of
`time.sleep(timeout)` because find() doesn't short-circuit on
the first response.
Extend `quick_timing` to also patch
`_FIRST_QUERY_DELAY_RANDOM_INTERVAL` to (1, 5) ms, drop
`LOOPBACK_FIND_TIMEOUT` from 200 → 75 ms (still ~7x headroom
over the ~10 ms response latency on loopback), and apply
`quick_timing` to the four `test_integration_with_*` tests in
tests/services/test_types.py.
Numbers on a local run:
test_integration_with_listener 0.67s → 0.20s
test_integration_with_listener_v6_records 0.69s → 0.19s
test_integration_with_subtype_and_listener 0.68s → 0.19s
test_integration_with_listener_ipv6 0.69s → 0.20s
test_async_zeroconf_service_types 0.74s → 0.55s
Full suite: 48.78s → 42.94s (-12%). Part of #1707.1 parent 65b22cb commit 76c31a7
3 files changed
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
0 commit comments