diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-15 18:13:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-15 18:13:15 -0700 |
commit | b8f748269584c1475f6e06aec48fce627f603880 (patch) | |
tree | 0f9fb17e97343e211e72e25eef038cf0748de4ba /activerecord/test | |
parent | 9a4bfd04a376efe91e8b80e754e6eab1e332eb69 (diff) | |
download | rails-b8f748269584c1475f6e06aec48fce627f603880.tar.gz rails-b8f748269584c1475f6e06aec48fce627f603880.tar.bz2 rails-b8f748269584c1475f6e06aec48fce627f603880.zip |
opening a connection will block if the pool is full
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/connection_pool_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb index da93500ce3..8dc9f761c2 100644 --- a/activerecord/test/cases/connection_pool_test.rb +++ b/activerecord/test/cases/connection_pool_test.rb @@ -96,6 +96,30 @@ module ActiveRecord end end + def test_full_pool_blocks + cs = @pool.size.times.map { @pool.checkout } + t = Thread.new { @pool.checkout } + + # make sure our thread is in the timeout section + Thread.pass until t.status == "sleep" + + connection = cs.first + connection.close + assert_equal connection, t.join.value + end + + def test_removing_releases_latch + cs = @pool.size.times.map { @pool.checkout } + t = Thread.new { @pool.checkout } + + # make sure our thread is in the timeout section + Thread.pass until t.status == "sleep" + + connection = cs.first + @pool.remove connection + assert_respond_to t.join.value, :execute + end + def test_reap_and_active @pool.checkout @pool.checkout |