aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/connection_pool_test.rb
diff options
context:
space:
mode:
authorJonathan Rochkind <jonathan@dnil.net>2012-09-21 12:35:11 -0400
committerJonathan Rochkind <jonathan@dnil.net>2012-09-24 16:20:22 -0400
commit39087068c2e3c85f6839ea51eab4480673138a2b (patch)
treef9b8a6120ff14d04115e6d31fa17d69035d9a9f1 /activerecord/test/cases/connection_pool_test.rb
parent7b545ff911a3f9bd3c9b179a2c6ac6b70bab3ee0 (diff)
downloadrails-39087068c2e3c85f6839ea51eab4480673138a2b.tar.gz
rails-39087068c2e3c85f6839ea51eab4480673138a2b.tar.bz2
rails-39087068c2e3c85f6839ea51eab4480673138a2b.zip
ConnectionPool accepts spec key 'checkout_timeout'
Backport of #6441 cb6f83935 . Old 'wait_timeout' is still supported, but conflicts with mysql2 using that spec key for different thing. 'checkout_timeout' can now be used taking precedence for ConnectionPool over 'wait_timeout'.
Diffstat (limited to 'activerecord/test/cases/connection_pool_test.rb')
-rw-r--r--activerecord/test/cases/connection_pool_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb
index 5cecfa90e7..98759544b6 100644
--- a/activerecord/test/cases/connection_pool_test.rb
+++ b/activerecord/test/cases/connection_pool_test.rb
@@ -151,6 +151,28 @@ module ActiveRecord
def test_pool_sets_connection_visitor
assert @pool.connection.visitor.is_a?(Arel::Visitors::ToSql)
end
+
+ def test_timeout_spec_keys
+ # 'wait_timeout' is supported for backwards compat,
+ # 'checkout_timeout' is preferred to avoid conflicting
+ # with mysql2 adapters key of name 'wait_timeout' but
+ # different meaning.
+ config = ActiveRecord::Base.connection_pool.spec.config.merge(:wait_timeout => nil, :connection_timeout => nil)
+ method = ActiveRecord::Base.connection_pool.spec.adapter_method
+
+ pool = ConnectionPool.new ActiveRecord::Base::ConnectionSpecification.new(config.merge(:wait_timeout => 1), method)
+ assert_equal 1, pool.instance_variable_get(:@timeout)
+ pool.disconnect!
+
+ pool = ConnectionPool.new ActiveRecord::Base::ConnectionSpecification.new(config.merge(:checkout_timeout => 1), method)
+ assert_equal 1, pool.instance_variable_get(:@timeout)
+ pool.disconnect!
+
+ pool = ConnectionPool.new ActiveRecord::Base::ConnectionSpecification.new(config.merge(:wait_timeout => 6000, :checkout_timeout => 1), method)
+ assert_equal 1, pool.instance_variable_get(:@timeout)
+ pool.disconnect!
+ end
+
end
end
end