mirror of
https://github.com/mperham/connection_pool
synced 2023-03-27 23:22:21 -04:00
Speed up test_with_timeout_override
This commit is contained in:
parent
64e97f5a8a
commit
ab1ecb2084
1 changed files with 9 additions and 5 deletions
|
@ -91,18 +91,22 @@ class TestConnectionPool < Minitest::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_with_timeout_override
|
def test_with_timeout_override
|
||||||
pool = ConnectionPool.new(:timeout => 0.05, :size => 1) { NetworkConnection.new }
|
pool = ConnectionPool.new(:timeout => 0, :size => 1) { NetworkConnection.new }
|
||||||
Thread.new do
|
|
||||||
|
t = Thread.new do
|
||||||
pool.with do |net|
|
pool.with do |net|
|
||||||
net.do_something
|
net.do_something
|
||||||
sleep 0.3
|
sleep 0.01
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sleep 0.05
|
|
||||||
|
Thread.pass while t.status == 'run'
|
||||||
|
|
||||||
assert_raises Timeout::Error do
|
assert_raises Timeout::Error do
|
||||||
pool.with { |net| net.do_something }
|
pool.with { |net| net.do_something }
|
||||||
end
|
end
|
||||||
pool.with(:timeout => 0.4) do |conn|
|
|
||||||
|
pool.with(:timeout => 0.1) do |conn|
|
||||||
refute_nil conn
|
refute_nil conn
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue