Namespace
Methods
S
T
Attributes
[R] pool
Instance Public methods
setup()
# File activerecord/test/cases/reaper_test.rb, line 8
def setup
  super
  @pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec
end
test_connection_pool_starts_reaper()
# File activerecord/test/cases/reaper_test.rb, line 61
def test_connection_pool_starts_reaper
  spec = ActiveRecord::Base.connection_pool.spec.dup
  spec.config[:reaping_frequency] = '0.0001'

  pool = ConnectionPool.new spec

  conn = nil
  child = Thread.new do
    conn = pool.checkout
    Thread.stop
  end
  Thread.pass while conn.nil?

  assert conn.in_use?

  child.terminate

  while conn.in_use?
    Thread.pass
  end
  assert !conn.in_use?
end
test_nil_time()

A reaper with nil time should never reap connections

# File activerecord/test/cases/reaper_test.rb, line 30
def test_nil_time
  fp = FakePool.new
  assert !fp.reaped
  reaper = ConnectionPool::Reaper.new(fp, nil)
  reaper.run
  assert !fp.reaped
end
test_pool_has_reaper()
# File activerecord/test/cases/reaper_test.rb, line 50
def test_pool_has_reaper
  assert pool.reaper
end
test_reaping_frequency_configuration()
# File activerecord/test/cases/reaper_test.rb, line 54
def test_reaping_frequency_configuration
  spec = ActiveRecord::Base.connection_pool.spec.dup
  spec.config[:reaping_frequency] = 100
  pool = ConnectionPool.new spec
  assert_equal 100, pool.reaper.frequency
end
test_some_time()
# File activerecord/test/cases/reaper_test.rb, line 38
def test_some_time
  fp = FakePool.new
  assert !fp.reaped

  reaper = ConnectionPool::Reaper.new(fp, 0.0001)
  reaper.run
  until fp.reaped
    Thread.pass
  end
  assert fp.reaped
end