1
0
Fork 0
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:
Ryuta Kamizono 2019-11-25 05:57:27 +09:00 committed by GitHub
commit be8b7674fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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