Skip to content

Commit fcd1ffb

Browse files
authored
test: give IPv6-only loopback find() its own timeout (#1721)
1 parent e32f52d commit fcd1ffb

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎tests/__init__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@
5151
# the registrar's response lands inside ~10ms and 75ms is ~7x headroom.
5252
LOOPBACK_FIND_TIMEOUT = 0.075
5353

54+
# IPv6-only `find()` on Linux GitHub runners can hit `[Errno 101] Network
55+
# is unreachable` on the `::1` socket and falls back to the `fe80::` link-
56+
# local interface, which adds latency the IPv4 loopback path never pays.
57+
# PyPy widens that further with JIT warmup. The 75ms budget that works on
58+
# IPv4 loopback is too tight for the V6Only path under those conditions
59+
# — give it more headroom.
60+
IPV6_LOOPBACK_FIND_TIMEOUT = 0.5
61+
5462

5563
class QuestionHistoryWithoutSuppression(QuestionHistory):
5664
def suppresses(self, question: DNSQuestion, now: float, known_answers: set[DNSRecord]) -> bool:

‎tests/services/test_types.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import zeroconf as r
1212
from zeroconf import ServiceInfo, Zeroconf, ZeroconfServiceTypes
1313

14-
from .. import LOOPBACK_FIND_TIMEOUT, _clear_cache, has_working_ipv6
14+
from .. import IPV6_LOOPBACK_FIND_TIMEOUT, LOOPBACK_FIND_TIMEOUT, _clear_cache, has_working_ipv6
1515

1616
log = logging.getLogger("zeroconf")
1717
original_logging_level = logging.NOTSET
@@ -116,11 +116,11 @@ def test_integration_with_listener_ipv6(quick_timing, disable_duplicate_packet_s
116116
zeroconf_registrar.registry.async_add(info)
117117
try:
118118
service_types = ZeroconfServiceTypes.find(
119-
ip_version=r.IPVersion.V6Only, timeout=LOOPBACK_FIND_TIMEOUT
119+
ip_version=r.IPVersion.V6Only, timeout=IPV6_LOOPBACK_FIND_TIMEOUT
120120
)
121121
assert type_ in service_types
122122
_clear_cache(zeroconf_registrar)
123-
service_types = ZeroconfServiceTypes.find(zc=zeroconf_registrar, timeout=LOOPBACK_FIND_TIMEOUT)
123+
service_types = ZeroconfServiceTypes.find(zc=zeroconf_registrar, timeout=IPV6_LOOPBACK_FIND_TIMEOUT)
124124
assert type_ in service_types
125125

126126
finally:

0 commit comments

Comments
 (0)