diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-08 13:33:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-08 13:33:01 +0300 |
commit | 6edb7e9bb152d919c215f35bd6cb7d52fd3d99be (patch) | |
tree | f12ef4b7953932f9b2b9c28313277bf636115bc8 /spec/lib/gitlab/database | |
parent | 305ea394efd2d5afe16234406dede486d9ca37af (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-ee
Diffstat (limited to 'spec/lib/gitlab/database')
-rw-r--r-- | spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb b/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb index f3ce5563e38..f824d4cefdf 100644 --- a/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb +++ b/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb @@ -140,6 +140,24 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do lb.read { raise conflict_error } end + context 'only primary is configured' do + let(:lb) do + config = Gitlab::Database::LoadBalancing::Configuration.new(ActiveRecord::Base) + allow(config).to receive(:load_balancing_enabled?).and_return(false) + + described_class.new(config) + end + + it 'does not retry a query on connection error if only the primary is configured' do + host = double(:host, query_cache_enabled: true) + + allow(lb).to receive(:host).and_return(host) + allow(host).to receive(:connection).and_raise(PG::UnableToSend) + + expect { lb.read }.to raise_error(PG::UnableToSend) + end + end + it 'uses the primary if no secondaries are available' do allow(lb).to receive(:connection_error?).and_return(true) |