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.
This commit is contained in:
Misaki Shioi 2024-11-12 19:14:05 +09:00 committed by GitHub
parent dc08d6e917
commit fee706d9dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-11-12 10:14:22 +00:00
Merged-By: shioimm <shioi.mm@gmail.com>

View File

@ -568,8 +568,8 @@ module TestNetHTTP_version_1_1_methods
conn.open_timeout = EnvUtil.apply_timeout_scale(0.1)
th = Thread.new do
err = !windows? ? Net::WriteTimeout : Net::ReadTimeout
assert_raise(err) do
err = !windows? ? [Net::WriteTimeout, Net::OpenTimeout] : Net::ReadTimeout
assert_raise(*err) do
assert_warning(/Content-Type did not set/) do
conn.post('/', "a"*50_000_000)
end
@ -600,7 +600,7 @@ module TestNetHTTP_version_1_1_methods
req.body_stream = StringIO.new(data)
th = Thread.new do
assert_raise(Net::WriteTimeout) { conn.request(req) }
assert_raise(Net::WriteTimeout, Net::OpenTimeout) { conn.request(req) }
end
assert th.join(10)
}