setting the connect timeout port as envvar

This commit is contained in:
HoneyryderChuck 2020-01-11 13:19:10 +00:00
parent dc6b3a6827
commit e4e04e9fe8
3 changed files with 7 additions and 3 deletions

View File

@ -58,7 +58,7 @@ class SessionTest < Minitest::Test
end
def test_session_timeout_connect_timeout
uri = build_uri("/", origin("127.0.0.1:9090"))
uri = build_uri("/", origin("127.0.0.1:#{CONNECT_TIMEOUT_PORT}"))
session = HTTPX.timeout(connect_timeout: 0.5, operation_timeout: 30, total_timeout: 2)
response = session.get(uri)
assert response.is_a?(HTTPX::ErrorResponse), "response should have failed (#{response.class})"

View File

@ -11,8 +11,10 @@ else
fi
# use port 9090 to test connection timeouts
iptables -A OUTPUT -p tcp -m tcp --tcp-flags SYN SYN --sport 9090 -j DROP
CONNECT_TIMEOUT_PORT=9090
iptables -A OUTPUT -p tcp -m tcp --tcp-flags SYN SYN --sport $CONNECT_TIMEOUT_PORT -j DROP
export CONNECT_TIMEOUT_PORT=$CONNECT_TIMEOUT_PORT
export PATH=$GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH
mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
gem install bundler -v="1.17.3" --no-doc --conservative

View File

@ -22,7 +22,9 @@ Dir[File.join(".", "test", "support", "**", "*.rb")].sort.each { |f| require f }
OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_file(ENV["SSL_CERT_FILE"]) if RUBY_VERSION.start_with?("2.3") && ENV.key?("SSL_CERT_FILE")
# 9090 drops SYN packets for connect timeout tests, make sure there's a server binding there.
server = TCPServer.new("127.0.0.1", 9090)
CONNECT_TIMEOUT_PORT = ENV.fetch("CONNECT_TIMEOUT_PORT", 9090).to_i
server = TCPServer.new("127.0.0.1", CONNECT_TIMEOUT_PORT)
Thread.start do
begin