fix desktop tests
docker / image (push) Failing after 5s
lint / ruff (push) Successful in 15s
tests / backend (push) Successful in 1m42s
tests / desktop (push) Successful in 24s
tests / web (push) Successful in 39s
tests / android-core (push) Successful in 39s
android / apk (push) Failing after 5m0s

This commit is contained in:
timka123 committed 2026-10-22 18:59:20 +03:00
1 parent d2f4e15fad
commit ea1ff48b97
1 file changed
+17 -12
+17 -12
View File
@@ -231,18 +231,23 @@ def test_junk_on_the_socket_does_not_take_the_stub_down(stub):
def test_a_dead_upstream_becomes_servfail(tmp_path): def test_a_dead_upstream_becomes_servfail(tmp_path):
resolver = StubResolver(ports=(0,), upstream_path=str(tmp_path / "empty.conf"), timeout=0.3) # A socket that is bound and listening but never answers. The upstream must
assert resolver.start() # be named explicitly: an empty or missing file falls back to the machine's
try: # /etc/resolv.conf, which in CI is Docker's resolver and *does* answer.
# The file does not exist and /etc/resolv.conf points at resolved, which with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as dead:
# is filtered out — so there is nowhere to forward to. dead.bind(("127.0.0.1", 0))
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: conf = tmp_path / "resolv.conf"
sock.settimeout(2) conf.write_text(f"nameserver 127.0.0.1:{dead.getsockname()[1]}\n")
sock.sendto(query("example.com"), ("127.0.0.1", resolver.port)) resolver = StubResolver(ports=(0,), upstream_path=str(conf), timeout=0.3)
response, _ = sock.recvfrom(4096) assert resolver.start()
assert response[3] & 0x0F == 2 # SERVFAIL, not a lie about the address try:
finally: with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
resolver.stop() sock.settimeout(2)
sock.sendto(query("example.com"), ("127.0.0.1", resolver.port))
response, _ = sock.recvfrom(4096)
assert response[3] & 0x0F == 2 # SERVFAIL, not a lie about the address
finally:
resolver.stop()
def test_upstreams_are_read_from_resolv_conf_and_loops_are_dropped(tmp_path): def test_upstreams_are_read_from_resolv_conf_and_loops_are_dropped(tmp_path):