Skip to content

Commit fee706d

Browse files
authored
Allow Net::HTTP#request to raise Net::OpenTimeout (#12062)
with a TCPSoerver that is only listening to avoid AssertionFailedError on Ubuntu. --- The tests such as `TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write` expect to raise a `Net::WriteTimeout` due to a failure in writing to the server. However, on Ubuntu environments, the server immediately returns a "Connection Refused" in such cases. The socket created with `TCPSocket.new` that supports HEv2 catches this immediately and raises a `Net::OpenTimeout`. As a result, these tests fail due to raising a different exception than expected. This PR adds `Net::OpenTimeout` asexceptions to avoid these test failures.
1 parent dc08d6e commit fee706d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/net/http/test_http.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ def test_timeout_during_HTTP_session_write
568568
conn.open_timeout = EnvUtil.apply_timeout_scale(0.1)
569569

570570
th = Thread.new do
571-
err = !windows? ? Net::WriteTimeout : Net::ReadTimeout
572-
assert_raise(err) do
571+
err = !windows? ? [Net::WriteTimeout, Net::OpenTimeout] : Net::ReadTimeout
572+
assert_raise(*err) do
573573
assert_warning(/Content-Type did not set/) do
574574
conn.post('/', "a"*50_000_000)
575575
end
@@ -600,7 +600,7 @@ def test_timeout_during_non_chunked_streamed_HTTP_session_write
600600
req.body_stream = StringIO.new(data)
601601

602602
th = Thread.new do
603-
assert_raise(Net::WriteTimeout) { conn.request(req) }
603+
assert_raise(Net::WriteTimeout, Net::OpenTimeout) { conn.request(req) }
604604
end
605605
assert th.join(10)
606606
}

0 commit comments

Comments
 (0)