mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #37789 from dr-itz/fix/ar-test-fork
fix(test): only test reaper with fork when fork is available
This commit is contained in:
commit
be8b7674fa
1 changed files with 21 additions and 19 deletions
|
@ -127,31 +127,33 @@ module ActiveRecord
|
|||
pool.flush
|
||||
end
|
||||
|
||||
def test_connection_pool_starts_reaper_in_fork
|
||||
pool_config = duplicated_pool_config
|
||||
pool_config.db_config.configuration_hash[:reaping_frequency] = "0.0001"
|
||||
if Process.respond_to?(:fork)
|
||||
def test_connection_pool_starts_reaper_in_fork
|
||||
pool_config = duplicated_pool_config
|
||||
pool_config.db_config.configuration_hash[:reaping_frequency] = "0.0001"
|
||||
|
||||
pool = ConnectionPool.new(pool_config)
|
||||
pool.checkout
|
||||
|
||||
pid = fork do
|
||||
pool = ConnectionPool.new(pool_config)
|
||||
pool.checkout
|
||||
|
||||
conn, child = new_conn_in_thread(pool)
|
||||
child.terminate
|
||||
pid = fork do
|
||||
pool = ConnectionPool.new(pool_config)
|
||||
|
||||
wait_for_conn_idle(conn)
|
||||
if conn.in_use?
|
||||
exit!(1)
|
||||
else
|
||||
exit!(0)
|
||||
conn, child = new_conn_in_thread(pool)
|
||||
child.terminate
|
||||
|
||||
wait_for_conn_idle(conn)
|
||||
if conn.in_use?
|
||||
exit!(1)
|
||||
else
|
||||
exit!(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Process.waitpid(pid)
|
||||
assert $?.success?
|
||||
ensure
|
||||
pool.discard!
|
||||
Process.waitpid(pid)
|
||||
assert $?.success?
|
||||
ensure
|
||||
pool.discard!
|
||||
end
|
||||
end
|
||||
|
||||
def test_reaper_does_not_reap_discarded_connection_pools
|
||||
|
|
Loading…
Reference in a new issue