mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Speed up slow ConnectionPool test case.
This commit is contained in:
parent
d5c1a5b1f5
commit
ce048a7a73
1 changed files with 19 additions and 11 deletions
|
@ -91,7 +91,9 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_full_pool_exception
|
def test_full_pool_exception
|
||||||
|
@pool.checkout_timeout = 0.001 # no need to delay test suite by waiting the whole full default timeout
|
||||||
@pool.size.times { assert @pool.checkout }
|
@pool.size.times { assert @pool.checkout }
|
||||||
|
|
||||||
assert_raises(ConnectionTimeoutError) do
|
assert_raises(ConnectionTimeoutError) do
|
||||||
@pool.checkout
|
@pool.checkout
|
||||||
end
|
end
|
||||||
|
@ -164,15 +166,19 @@ module ActiveRecord
|
||||||
idle_conn = @pool.checkout
|
idle_conn = @pool.checkout
|
||||||
@pool.checkin(idle_conn)
|
@pool.checkin(idle_conn)
|
||||||
|
|
||||||
def idle_conn.seconds_idle
|
idle_conn.instance_variable_set(
|
||||||
@seconds_idle
|
:@idle_since,
|
||||||
end
|
Concurrent.monotonic_time - 0.01
|
||||||
|
)
|
||||||
|
|
||||||
idle_conn.instance_variable_set(:@seconds_idle, 0.01)
|
|
||||||
@pool.flush
|
@pool.flush
|
||||||
assert_equal 1, @pool.connections.length
|
assert_equal 1, @pool.connections.length
|
||||||
|
|
||||||
idle_conn.instance_variable_set(:@seconds_idle, 0.02)
|
idle_conn.instance_variable_set(
|
||||||
|
:@idle_since,
|
||||||
|
Concurrent.monotonic_time - 0.02
|
||||||
|
)
|
||||||
|
|
||||||
@pool.flush
|
@pool.flush
|
||||||
assert_equal 0, @pool.connections.length
|
assert_equal 0, @pool.connections.length
|
||||||
end
|
end
|
||||||
|
@ -185,9 +191,10 @@ module ActiveRecord
|
||||||
idle_conn = @pool.checkout
|
idle_conn = @pool.checkout
|
||||||
@pool.checkin(idle_conn)
|
@pool.checkin(idle_conn)
|
||||||
|
|
||||||
def idle_conn.seconds_idle
|
idle_conn.instance_variable_set(
|
||||||
1
|
:@idle_since,
|
||||||
end
|
Concurrent.monotonic_time - 1
|
||||||
|
)
|
||||||
|
|
||||||
@pool.flush
|
@pool.flush
|
||||||
assert_equal 1, @pool.connections.length
|
assert_equal 1, @pool.connections.length
|
||||||
|
@ -203,9 +210,10 @@ module ActiveRecord
|
||||||
|
|
||||||
assert_equal 3, @pool.connections.length
|
assert_equal 3, @pool.connections.length
|
||||||
|
|
||||||
def idle_conn.seconds_idle
|
idle_conn.instance_variable_set(
|
||||||
1000
|
:@idle_since,
|
||||||
end
|
Concurrent.monotonic_time - 1000
|
||||||
|
)
|
||||||
|
|
||||||
@pool.flush(30)
|
@pool.flush(30)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue