summaryrefslogtreecommitdiff
path: root/test/net/http
diff options
context:
space:
mode:
authorMisaki Shioi <[email protected]>2024-11-12 19:14:05 +0900
committerGitHub <[email protected]>2024-11-12 19:14:05 +0900
commitfee706d9dd52d7f0444357259f33d335f21c980b (patch)
tree16bac6f4251ce23840ae1bf1140d1006447c778b /test/net/http
parentdc08d6e9172c655c770d91c5d5fba5beda431a7d (diff)
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.
Notes
Notes: Merged-By: shioimm <[email protected]>
Diffstat (limited to 'test/net/http')
-rw-r--r--test/net/http/test_http.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index a49cc87e8d..25fdeadbd2 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -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)
}