Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/database/load_balancing/configuration_spec.rb')
-rw-r--r--spec/lib/gitlab/database/load_balancing/configuration_spec.rb61
1 files changed, 2 insertions, 59 deletions
diff --git a/spec/lib/gitlab/database/load_balancing/configuration_spec.rb b/spec/lib/gitlab/database/load_balancing/configuration_spec.rb
index 77284b4d128..34370c9a21f 100644
--- a/spec/lib/gitlab/database/load_balancing/configuration_spec.rb
+++ b/spec/lib/gitlab/database/load_balancing/configuration_spec.rb
@@ -100,14 +100,6 @@ RSpec.describe Gitlab::Database::LoadBalancing::Configuration, :request_store do
expect(config.pool_size).to eq(4)
end
end
-
- it 'calls reuse_primary_connection!' do
- expect_next_instance_of(described_class) do |subject|
- expect(subject).to receive(:reuse_primary_connection!).and_call_original
- end
-
- described_class.for_model(model)
- end
end
describe '#load_balancing_enabled?' do
@@ -203,61 +195,12 @@ RSpec.describe Gitlab::Database::LoadBalancing::Configuration, :request_store do
end
end
- describe '#replica_db_config' do
+ describe '#db_config' do
let(:model) { double(:model, connection_db_config: db_config, connection_specification_name: 'Ci::ApplicationRecord') }
let(:config) { described_class.for_model(model) }
it 'returns exactly db_config' do
- expect(config.replica_db_config).to eq(db_config)
- end
-
- context 'when GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci=main' do
- it 'does not change replica_db_config' do
- stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', 'main')
-
- expect(config.replica_db_config).to eq(db_config)
- end
- end
- end
-
- describe 'reuse_primary_connection!' do
- let(:model) { double(:model, connection_db_config: db_config, connection_specification_name: 'Ci::ApplicationRecord') }
- let(:config) { described_class.for_model(model) }
-
- context 'when GITLAB_LOAD_BALANCING_REUSE_PRIMARY_* not configured' do
- it 'the primary connection uses default specification' do
- stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', nil)
-
- expect(config.primary_connection_specification_name).to eq('Ci::ApplicationRecord')
- end
- end
-
- context 'when GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci=main' do
- before do
- stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', 'main')
- end
-
- it 'the primary connection uses main connection' do
- expect(config.primary_connection_specification_name).to eq('ActiveRecord::Base')
- end
-
- context 'when force_no_sharing_primary_model feature flag is enabled' do
- before do
- stub_feature_flags(force_no_sharing_primary_model: true)
- end
-
- it 'the primary connection uses ci connection' do
- expect(config.primary_connection_specification_name).to eq('Ci::ApplicationRecord')
- end
- end
- end
-
- context 'when GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci=unknown' do
- it 'raises exception' do
- stub_env('GITLAB_LOAD_BALANCING_REUSE_PRIMARY_ci', 'unknown')
-
- expect { config.reuse_primary_connection! }.to raise_error /Invalid value for/
- end
+ expect(config.db_config).to eq(db_config)
end
end
end