Skip to content

Commit a0977a1

Browse files
authored
Clear cache in ZeroconfServiceTypes tests to ensure responses can be mcast before the timeout (#634)
- We prevent the same record from being multicast within 1s because of RFC6762 sec 14. Since these test timeout after 0.5s, the answers they are looking for many be suppressed. Since a legitimate querier will retry again later, we need to clear the cache to simulate that the record has not been multicast recently
1 parent 5f66caa commit a0977a1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tests/services/test_types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_integration_with_listener(self):
3535
addresses=[socket.inet_aton("10.0.1.2")],
3636
)
3737
zeroconf_registrar.register_service(info)
38-
38+
_clear_cache(zeroconf_registrar)
3939
try:
4040
service_types = ZeroconfServiceTypes.find(interfaces=['127.0.0.1'], timeout=0.5)
4141
assert type_ in service_types
@@ -68,7 +68,7 @@ def test_integration_with_listener_v6_records(self):
6868
addresses=[socket.inet_pton(socket.AF_INET6, addr)],
6969
)
7070
zeroconf_registrar.register_service(info)
71-
71+
_clear_cache(zeroconf_registrar)
7272
try:
7373
service_types = ZeroconfServiceTypes.find(interfaces=['127.0.0.1'], timeout=0.5)
7474
assert type_ in service_types
@@ -100,7 +100,7 @@ def test_integration_with_listener_ipv6(self):
100100
addresses=[socket.inet_aton("10.0.1.2")],
101101
)
102102
zeroconf_registrar.register_service(info)
103-
103+
_clear_cache(zeroconf_registrar)
104104
try:
105105
service_types = ZeroconfServiceTypes.find(ip_version=r.IPVersion.V6Only, timeout=0.5)
106106
assert type_ in service_types
@@ -132,7 +132,7 @@ def test_integration_with_subtype_and_listener(self):
132132
addresses=[socket.inet_aton("10.0.1.2")],
133133
)
134134
zeroconf_registrar.register_service(info)
135-
135+
_clear_cache(zeroconf_registrar)
136136
try:
137137
service_types = ZeroconfServiceTypes.find(interfaces=['127.0.0.1'], timeout=0.5)
138138
assert discovery_type in service_types

0 commit comments

Comments
 (0)