Compare commits

...

8 Commits

Author SHA1 Message Date
HoneyryderChuck
c99194e298 Merge branch 'improvs' 2023-01-25 00:59:07 +00:00
HoneyryderChuck
6881dd2bc4 disable ipv6 connectivity when ip address list does not contain an ip address which is also not sitelocal 2023-01-25 00:58:49 +00:00
HoneyryderChuck
7604d9deb9 adapt timeout of regression test 2023-01-25 00:58:49 +00:00
HoneyryderChuck
d7431e76a2 log ip family for logged dns answer 2023-01-25 00:58:49 +00:00
HoneyryderChuck
efaa0e8066 fix for delayed IPv4 from Happy Eyeballs coalescing after
If the Ipv4 handshake works in dual stack, and there is an open
connection to be used, the tcp_open callback wasn't being called, and
the process halted. The fix was to emit :tcp_open before coalescing, as
this allows for the original conn state to be merged first with the new
conn, then with the connection to coalesce.
2023-01-25 00:58:49 +00:00
HoneyryderChuck
d0fcd13bf2 moving regression tests outside of docker 2023-01-25 00:58:49 +00:00
HoneyryderChuck
0a35b125f4 linting previous test 2023-01-25 00:58:49 +00:00
HoneyryderChuck
a6cfaf4ec3 do not test mjit, only test yjit for ruby 3.2 2023-01-25 00:58:49 +00:00
8 changed files with 36 additions and 26 deletions

View File

@ -30,7 +30,7 @@ variables:
.yjit_matrix: &yjit_matrix .yjit_matrix: &yjit_matrix
parallel: parallel:
matrix: matrix:
- RUBYOPT: ["", "--jit --jit-warnings --jit-wait", "--yjit"] - RUBYOPT: ["", "--yjit"]
# Cache gems in between builds # Cache gems in between builds
cache: cache:
@ -81,11 +81,14 @@ test ruby 2/7:
./spec.sh ruby 2.7 ./spec.sh ruby 2.7
test ruby 3/0: test ruby 3/0:
<<: *test_settings <<: *test_settings
only:
- master
script: script:
./spec.sh ruby 3.0 ./spec.sh ruby 3.0
test ruby 3/1: test ruby 3/1:
<<: *test_settings <<: *test_settings
<<: *yjit_matrix only:
- master
script: script:
./spec.sh ruby 3.1 ./spec.sh ruby 3.1
test ruby 3/2: test ruby 3/2:
@ -98,6 +101,21 @@ test truffleruby:
script: script:
./spec.sh truffleruby latest ./spec.sh truffleruby latest
allow_failure: true allow_failure: true
regression tests:
image: "ruby:3.2"
variables:
BUNDLE_WITHOUT: assorted
CI: 1
COVERAGE_KEY: "$RUBY_ENGINE-$RUBY_VERSION-regression-tests"
artifacts:
paths:
- coverage/
stage: test
before_script:
- apt-get update && apt-get install -y libmagic-dev shared-mime-info
- bundle install
script:
- bundle exec rake regression_tests
coverage: coverage:
coverage: '/\(\d+.\d+\%\) covered/' coverage: '/\(\d+.\d+\%\) covered/'

View File

@ -557,7 +557,7 @@ module HTTPX
return if @state == :closed return if @state == :closed
@io.connect @io.connect
emit(:tcp_open) if @io.state == :connected emit(:tcp_open, self) if @io.state == :connected
return unless @io.connected? return unless @io.connected?

View File

@ -15,7 +15,7 @@ module HTTPX
# https://github.com/ruby/resolv/blob/095f1c003f6073730500f02acbdbc55f83d70987/lib/resolv.rb#L408 # https://github.com/ruby/resolv/blob/095f1c003f6073730500f02acbdbc55f83d70987/lib/resolv.rb#L408
ip_address_families = begin ip_address_families = begin
list = Socket.ip_address_list list = Socket.ip_address_list
if list.any? { |a| a.ipv6? && !a.ipv6_loopback? && !a.ipv6_linklocal? } if list.any? { |a| a.ipv6? && !a.ipv6_loopback? && !a.ipv6_linklocal? && !a.ipv6_unique_local? }
[Socket::AF_INET6, Socket::AF_INET] [Socket::AF_INET6, Socket::AF_INET]
else else
[Socket::AF_INET] [Socket::AF_INET]

View File

@ -137,7 +137,7 @@ module HTTPX
new_connection = connection.class.new(connection.type, connection.origin, connection.options) new_connection = connection.class.new(connection.type, connection.origin, connection.options)
new_connection.family = family new_connection.family = family
connection.once(:tcp_open, &new_connection.method(:force_reset)) connection.once(:tcp_open) { new_connection.force_reset }
connection.once(:connect_error) do |err| connection.once(:connect_error) do |err|
if new_connection.connecting? if new_connection.connecting?
new_connection.merge(connection) new_connection.merge(connection)
@ -146,8 +146,8 @@ module HTTPX
end end
end end
new_connection.once(:tcp_open) do new_connection.once(:tcp_open) do |new_conn|
new_connection.merge(connection) new_conn.merge(connection)
connection.force_reset connection.force_reset
end end
new_connection.once(:connect_error) do |err| new_connection.once(:connect_error) do |err|
@ -222,6 +222,7 @@ module HTTPX
def coalesce_connections(conn1, conn2) def coalesce_connections(conn1, conn2)
return register_connection(conn2) unless conn1.coalescable?(conn2) return register_connection(conn2) unless conn1.coalescable?(conn2)
conn2.emit(:tcp_open, conn1)
conn1.merge(conn2) conn1.merge(conn2)
@connections.delete(conn2) @connections.delete(conn2)
end end

View File

@ -54,7 +54,7 @@ module HTTPX
# double emission check # double emission check
return if connection.addresses && !addresses.intersect?(connection.addresses) return if connection.addresses && !addresses.intersect?(connection.addresses)
log { "resolver: answer #{connection.origin.host}: #{addresses.inspect}" } log { "resolver: answer #{FAMILY_TYPES[RECORD_TYPES[family]]} #{connection.origin.host}: #{addresses.inspect}" }
if @pool && # if triggered by early resolve, pool may not be here yet if @pool && # if triggered by early resolve, pool may not be here yet
!connection.io && !connection.io &&
connection.options.ip_families.size > 1 && connection.options.ip_families.size > 1 &&

View File

@ -8,7 +8,7 @@ class Bug_0_18_2_Test < Minitest::Test
include HTTPHelpers include HTTPHelpers
def test_no_loop_forever_when_total_timeout_on_persistent def test_no_loop_forever_when_total_timeout_on_persistent
session = HTTPX.plugin(:persistent).with_timeout(total_timeout: 1) session = HTTPX.plugin(:persistent).with_timeout(total_timeout: 5)
response1 = session.get("https://#{httpbin}/get") response1 = session.get("https://#{httpbin}/get")
sleep 2 sleep 2

View File

@ -9,8 +9,8 @@ class Bug_0_22_2_Test < Minitest::Test
Plugin = Module.new do Plugin = Module.new do
@connections = [] @connections = []
def self.connections class << self
@connections attr_reader :connections
end end
self::ConnectionMethods = Module.new do self::ConnectionMethods = Module.new do
@ -22,11 +22,12 @@ class Bug_0_22_2_Test < Minitest::Test
end end
def test_happy_eyeballs_v2_use_correct_family def test_happy_eyeballs_v2_use_correct_family
connections = [] ipv4_host = "badipv6.test.ipv6friday.org"
ipv6_host = "badipv4.test.ipv6friday.org"
HTTPX.plugin(Plugin).wrap do |http| HTTPX.plugin(Plugin).wrap do |http|
response_ipv4 = http.get("http://#{ipv4_host}") _response_ipv4 = http.get("http://#{ipv4_host}")
response_ipv6 = http.get("http://#{ipv6_host}") _response_ipv6 = http.get("http://#{ipv6_host}")
end end
assert Plugin.connections.size == 2 assert Plugin.connections.size == 2
connection_ipv4 = Plugin.connections.find { |conn| conn.origin.to_s == "http://#{ipv4_host}" } connection_ipv4 = Plugin.connections.find { |conn| conn.origin.to_s == "http://#{ipv4_host}" }
@ -35,14 +36,4 @@ class Bug_0_22_2_Test < Minitest::Test
assert connection_ipv4.family == Socket::AF_INET assert connection_ipv4.family == Socket::AF_INET
assert connection_ipv6.family == Socket::AF_INET6 assert connection_ipv6.family == Socket::AF_INET6
end end
end if HTTPX::Session.default_options.ip_families.size > 1
private
def ipv4_host
"badipv6.test.ipv6friday.org"
end
def ipv6_host
"badipv4.test.ipv6friday.org"
end
end

View File

@ -97,7 +97,7 @@ fi
if [[ ${RUBY_VERSION:0:3} = "3.2" ]] && [[ "$RUBY_ENGINE" = "ruby" ]]; then if [[ ${RUBY_VERSION:0:3} = "3.2" ]] && [[ "$RUBY_ENGINE" = "ruby" ]]; then
# regression tests # regression tests
# Testing them only with main ruby # Testing them only with main ruby
COVERAGE_KEY="$RUBY_ENGINE-$RUBY_VERSION-regression-tests" bundle exec rake regression_tests # COVERAGE_KEY="$RUBY_ENGINE-$RUBY_VERSION-regression-tests" bundle exec rake regression_tests
# standalone tests # standalone tests
for f in standalone_tests/*_test.rb; do for f in standalone_tests/*_test.rb; do