Skip to content

Commit

Permalink
test_dns: Fix failure on Windows (#58)
Browse files Browse the repository at this point in the history
test_dns: Fix failure on Windows

1. Switch to #with_udp_and_tcp helper method for EACCES retries on Windows;
   the given UDP socket is unnecessary though.
2. Using 127.0.0.1 should be fine, as it must give different host:port pair.
3. On Windows, 5 retries of bind(2) appears still flaky, doubling it for sure.

follow-up: #50
follow-up: 6252914
  • Loading branch information
sorah authored Aug 13, 2024
1 parent 6252914 commit 0a0d57e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/resolv/test_dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def with_udp(host, port)
def with_udp_and_tcp(host, port)
if port == 0
# Automatic port; we might need to retry until we find a port which is free on both UDP _and_ TCP.
retries_remaining = 5
retries_remaining = 10
t = nil
u = nil
begin
Expand Down Expand Up @@ -709,7 +709,8 @@ def test_multiple_servers_with_timeout_and_truncated_tcp_fallback
num_records = 50

with_udp_and_tcp('127.0.0.1', 0) do |u1, t1|
with_tcp('0.0.0.0', 0) do |t2|
with_udp_and_tcp('127.0.0.1', 0) do |u2,t2|
u2.close # XXX: u2 UDP socket is not used, but using #with_udp_and_tcp to enable Windows EACCES workaround
_, server1_port, _, server1_address = u1.addr
_, server2_port, _, server2_address = t2.addr

Expand Down

0 comments on commit 0a0d57e

Please sign in to comment.