using session pool for coalescing test, thereby minimizing interference (although it would have been nice to have more entropy)

This commit is contained in:
HoneyryderChuck 2021-01-05 10:36:14 +00:00
parent cdf6868059
commit a6176ec01f
2 changed files with 6 additions and 4 deletions

View File

@ -31,15 +31,15 @@ class HTTPSTest < Minitest::Test
def test_connection_coalescing
coalesced_origin = "https://#{ENV["HTTPBIN_COALESCING_HOST"]}"
HTTPX.wrap do |http|
HTTPX.plugin(SessionWithPool).wrap do |http|
response1 = http.get(origin)
verify_status(response1, 200)
response2 = http.get(coalesced_origin)
verify_status(response2, 200)
# introspection time
pool = http.__send__(:pool)
connections = pool.instance_variable_get(:@connections)
origins = connections.map { |conn| conn.instance_variable_get(:@origins) }
pool = http.pool
connections = pool.connections
origins = connections.map(&:origins)
assert origins.any? { |orgs| orgs.sort == [origin, coalesced_origin].sort },
"connections for #{[origin, coalesced_origin]} didn't coalesce (expected connection with both origins (#{origins}))"
end

View File

@ -35,6 +35,8 @@ module SessionWithPool
end
module ConnectionMethods
attr_reader :origins
def set_parser_callbacks(parser)
super
parser.on(:pong) { emit(:pong) }