Sha256: e7468328b12a2980906bd119a923046b3adac58a951e95743cad87ff97cc0d34
Contents?: true
Size: 1.85 KB
Versions: 16
Compression:
Stored size: 1.85 KB
Contents
require File.expand_path(File.dirname(__FILE__)) + '/../unit_helper' require 'lhm/throttler/threads_running' describe Lhm::Throttler::ThreadsRunning do include UnitHelper before :each do @throttler = Lhm::Throttler::ThreadsRunning.new end describe '#throttle_seconds' do describe 'with no mysql activity' do before do def @throttler.threads_running 0 end end it 'does not alter the currently set timeout' do timeout = @throttler.timeout_seconds assert_equal(timeout, @throttler.send(:throttle_seconds)) end end describe 'with an overloaded mysql' do before do def @throttler.threads_running 100 end end it 'doubles the currently set timeout' do timeout = @throttler.timeout_seconds assert_equal(timeout * 2, @throttler.send(:throttle_seconds)) end it 'does not increase the timeout past the maximum' do @throttler.timeout_seconds = @throttler.max_timeout_seconds assert_equal(@throttler.max_timeout_seconds, @throttler.send(:throttle_seconds)) end end describe 'with an idle mysql after it has previously been busy' do before do def @throttler.threads_running 0 end end it 'halves the currently set timeout' do @throttler.timeout_seconds *= 2 * 2 timeout = @throttler.timeout_seconds assert_equal(timeout / 2, @throttler.send(:throttle_seconds)) end it 'does not decrease the timeout past the minimum on repeated runs' do @throttler.timeout_seconds = @throttler.initial_timeout_seconds * 2 assert_equal(@throttler.initial_timeout_seconds, @throttler.send(:throttle_seconds)) assert_equal(@throttler.initial_timeout_seconds, @throttler.send(:throttle_seconds)) end end end end
Version data entries
16 entries across 16 versions & 2 rubygems