Skip to content

Commit a3ebdae

Browse files
committed
gh-75743: Remove test_timeout.testConnectTimeout()
Remove test_timeout.testConnectTimeout() which is always skipped since 2009, commit 5b95a15. No replacement was found for blackhole.snakebite.net and whitehole.snakebite.net online servers.
1 parent e7d5433 commit a3ebdae

File tree

1 file changed

+0
-83
lines changed

1 file changed

+0
-83
lines changed

Lib/test/test_timeout.py

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from test.support import socket_helper
77

88
import time
9-
import errno
109
import socket
1110

1211

@@ -148,88 +147,6 @@ def setUp(self):
148147
def tearDown(self):
149148
self.sock.close()
150149

151-
@unittest.skipIf(True, 'need to replace these hosts; see bpo-35518')
152-
def testConnectTimeout(self):
153-
# Testing connect timeout is tricky: we need to have IP connectivity
154-
# to a host that silently drops our packets. We can't simulate this
155-
# from Python because it's a function of the underlying TCP/IP stack.
156-
# So, the following Snakebite host has been defined:
157-
blackhole = resolve_address('blackhole.snakebite.net', 56666)
158-
159-
# Blackhole has been configured to silently drop any incoming packets.
160-
# No RSTs (for TCP) or ICMP UNREACH (for UDP/ICMP) will be sent back
161-
# to hosts that attempt to connect to this address: which is exactly
162-
# what we need to confidently test connect timeout.
163-
164-
# However, we want to prevent false positives. It's not unreasonable
165-
# to expect certain hosts may not be able to reach the blackhole, due
166-
# to firewalling or general network configuration. In order to improve
167-
# our confidence in testing the blackhole, a corresponding 'whitehole'
168-
# has also been set up using one port higher:
169-
whitehole = resolve_address('whitehole.snakebite.net', 56667)
170-
171-
# This address has been configured to immediately drop any incoming
172-
# packets as well, but it does it respectfully with regards to the
173-
# incoming protocol. RSTs are sent for TCP packets, and ICMP UNREACH
174-
# is sent for UDP/ICMP packets. This means our attempts to connect to
175-
# it should be met immediately with ECONNREFUSED. The test case has
176-
# been structured around this premise: if we get an ECONNREFUSED from
177-
# the whitehole, we proceed with testing connect timeout against the
178-
# blackhole. If we don't, we skip the test (with a message about not
179-
# getting the required RST from the whitehole within the required
180-
# timeframe).
181-
182-
# For the records, the whitehole/blackhole configuration has been set
183-
# up using the 'pf' firewall (available on BSDs), using the following:
184-
#
185-
# ext_if="bge0"
186-
#
187-
# blackhole_ip="35.8.247.6"
188-
# whitehole_ip="35.8.247.6"
189-
# blackhole_port="56666"
190-
# whitehole_port="56667"
191-
#
192-
# block return in log quick on $ext_if proto { tcp udp } \
193-
# from any to $whitehole_ip port $whitehole_port
194-
# block drop in log quick on $ext_if proto { tcp udp } \
195-
# from any to $blackhole_ip port $blackhole_port
196-
#
197-
198-
skip = True
199-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
200-
timeout = support.LOOPBACK_TIMEOUT
201-
sock.settimeout(timeout)
202-
try:
203-
sock.connect((whitehole))
204-
except TimeoutError:
205-
pass
206-
except OSError as err:
207-
if err.errno == errno.ECONNREFUSED:
208-
skip = False
209-
finally:
210-
sock.close()
211-
del sock
212-
213-
if skip:
214-
self.skipTest(
215-
"We didn't receive a connection reset (RST) packet from "
216-
"{}:{} within {} seconds, so we're unable to test connect "
217-
"timeout against the corresponding {}:{} (which is "
218-
"configured to silently drop packets)."
219-
.format(
220-
whitehole[0],
221-
whitehole[1],
222-
timeout,
223-
blackhole[0],
224-
blackhole[1],
225-
)
226-
)
227-
228-
# All that hard work just to test if connect times out in 0.001s ;-)
229-
self.addr_remote = blackhole
230-
with socket_helper.transient_internet(self.addr_remote[0]):
231-
self._sock_operation(1, 0.001, 'connect', self.addr_remote)
232-
233150
def testRecvTimeout(self):
234151
# Test recv() timeout
235152
with socket_helper.transient_internet(self.addr_remote[0]):

0 commit comments

Comments
 (0)