Methods
- A
- S
- T
Attributes
| [R] | pool |
Instance Public methods
active_connections(pool)
Link
setup()
Link
# File activerecord/test/cases/connection_pool_test.rb, line 8 def setup super # Keep a duplicate pool so we do not bother others @pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec if in_memory_db? # Separate connections to an in-memory database create an entirely new database, # with an empty schema etc, so we just stub out this schema on the fly. @pool.with_connection do |connection| connection.create_table :posts do |t| t.integer :cololumn end end end end
teardown()
Link
test_active_connection?()
Link
test_active_connection_in_use()
Link
test_automatic_reconnect=()
Link
# File activerecord/test/cases/connection_pool_test.rb, line 131 def test_automatic_reconnect= pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec assert pool.automatic_reconnect assert pool.connection pool.disconnect! assert pool.connection pool.disconnect! pool.automatic_reconnect = false assert_raises(ConnectionNotEstablished) do pool.connection end assert_raises(ConnectionNotEstablished) do pool.with_connection end end
test_checkout_after_close()
Link
test_checkout_behaviour()
Link
# File activerecord/test/cases/connection_pool_test.rb, line 99 def test_checkout_behaviour pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec connection = pool.connection assert_not_nil connection threads = [] 4.times do |i| threads << Thread.new(i) do |pool_count| connection = pool.connection assert_not_nil connection end end threads.each {|t| t.join} Thread.new do threads.each do |t| thread_ids = pool.instance_variable_get(:@reserved_connections).keys assert thread_ids.include?(t.object_id) end assert_deprecated do pool.connection end threads.each do |t| thread_ids = pool.instance_variable_get(:@reserved_connections).keys assert !thread_ids.include?(t.object_id) end pool.connection.close end.join end
test_pool_sets_connection_visitor()
Link
test_released_connection_moves_between_threads()
Link
# File activerecord/test/cases/connection_pool_test.rb, line 44 def test_released_connection_moves_between_threads thread_conn = nil Thread.new { pool.with_connection do |conn| thread_conn = conn end }.join assert thread_conn Thread.new { pool.with_connection do |conn| assert_equal thread_conn, conn end }.join end
test_timeout_spec_keys()
Link
# File activerecord/test/cases/connection_pool_test.rb, line 155 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
test_with_connection()
Link
# File activerecord/test/cases/connection_pool_test.rb, line 62 def test_with_connection assert_equal 0, active_connections(pool).size main_thread = pool.connection assert_equal 1, active_connections(pool).size Thread.new { pool.with_connection do |conn| assert conn assert_equal 2, active_connections(pool).size end assert_equal 1, active_connections(pool).size }.join main_thread.close assert_equal 0, active_connections(pool).size end