mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-11-29 00:01:06 -05:00
using session pool for coalescing test, thereby minimizing interference (although it would have been nice to have more entropy)
This commit is contained in:
parent
cdf6868059
commit
a6176ec01f
@ -31,15 +31,15 @@ class HTTPSTest < Minitest::Test
|
|||||||
|
|
||||||
def test_connection_coalescing
|
def test_connection_coalescing
|
||||||
coalesced_origin = "https://#{ENV["HTTPBIN_COALESCING_HOST"]}"
|
coalesced_origin = "https://#{ENV["HTTPBIN_COALESCING_HOST"]}"
|
||||||
HTTPX.wrap do |http|
|
HTTPX.plugin(SessionWithPool).wrap do |http|
|
||||||
response1 = http.get(origin)
|
response1 = http.get(origin)
|
||||||
verify_status(response1, 200)
|
verify_status(response1, 200)
|
||||||
response2 = http.get(coalesced_origin)
|
response2 = http.get(coalesced_origin)
|
||||||
verify_status(response2, 200)
|
verify_status(response2, 200)
|
||||||
# introspection time
|
# introspection time
|
||||||
pool = http.__send__(:pool)
|
pool = http.pool
|
||||||
connections = pool.instance_variable_get(:@connections)
|
connections = pool.connections
|
||||||
origins = connections.map { |conn| conn.instance_variable_get(:@origins) }
|
origins = connections.map(&:origins)
|
||||||
assert origins.any? { |orgs| orgs.sort == [origin, coalesced_origin].sort },
|
assert origins.any? { |orgs| orgs.sort == [origin, coalesced_origin].sort },
|
||||||
"connections for #{[origin, coalesced_origin]} didn't coalesce (expected connection with both origins (#{origins}))"
|
"connections for #{[origin, coalesced_origin]} didn't coalesce (expected connection with both origins (#{origins}))"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -35,6 +35,8 @@ module SessionWithPool
|
|||||||
end
|
end
|
||||||
|
|
||||||
module ConnectionMethods
|
module ConnectionMethods
|
||||||
|
attr_reader :origins
|
||||||
|
|
||||||
def set_parser_callbacks(parser)
|
def set_parser_callbacks(parser)
|
||||||
super
|
super
|
||||||
parser.on(:pong) { emit(:pong) }
|
parser.on(:pong) { emit(:pong) }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user