diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-03 16:42:02 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-06 10:50:03 +0200 |
commit | 640a4c88341f790ede78f845d29a37634030581f (patch) | |
tree | 85fde39e674cc395a65bc4d647a700cbefa9619e /spec/lib | |
parent | 0bbeff3d5e6c1b5ea3b364f052ed6f777c3aa645 (diff) | |
download | gitlab-ce-640a4c88341f790ede78f845d29a37634030581f.tar.gz |
Use higher size on Gitlab::Redis connection pool on Sidekiq servers
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/redis_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/gitlab/redis_spec.rb b/spec/lib/gitlab/redis_spec.rb index cb54c020b31..74ff85e132a 100644 --- a/spec/lib/gitlab/redis_spec.rb +++ b/spec/lib/gitlab/redis_spec.rb @@ -88,6 +88,34 @@ describe Gitlab::Redis do end end + describe '.with' do + before { clear_pool } + after { clear_pool } + + context 'when running not on sidekiq workers' do + before { allow(Sidekiq).to receive(:server?).and_return(false) } + + it 'instantiates a connection pool with size 5' do + expect(ConnectionPool).to receive(:new).with(size: 5).and_call_original + + described_class.with { |_redis| true } + end + end + + context 'when running on sidekiq workers' do + before do + allow(Sidekiq).to receive(:server?).and_return(true) + allow(Sidekiq).to receive(:options).and_return({ concurrency: 18 }) + end + + it 'instantiates a connection pool with a size based on the concurrency of the worker' do + expect(ConnectionPool).to receive(:new).with(size: 18 + 5).and_call_original + + described_class.with { |_redis| true } + end + end + end + describe '#raw_config_hash' do it 'returns default redis url when no config file is present' do expect(subject).to receive(:fetch_config) { false } @@ -114,4 +142,10 @@ describe Gitlab::Redis do rescue NameError # raised if @_raw_config was not set; ignore end + + def clear_pool + described_class.remove_instance_variable(:@pool) + rescue NameError + # raised if @pool was not set; ignore + end end |