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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-01 18:08:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-01 18:08:40 +0300
commitcdd826bc3ad3e6f234f96a861efa129dba5e2502 (patch)
treeb159419c3a731637f35e95fe62f30ad437356996 /spec/tasks
parente4a0b94a64dc5bd8f48430cd5cdf9aaa10927e75 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/db/validate_config_rake_spec.rb12
-rw-r--r--spec/tasks/gitlab/setup_rake_spec.rb10
2 files changed, 21 insertions, 1 deletions
diff --git a/spec/tasks/gitlab/db/validate_config_rake_spec.rb b/spec/tasks/gitlab/db/validate_config_rake_spec.rb
index 4924ecc0ec9..7b2f37414a0 100644
--- a/spec/tasks/gitlab/db/validate_config_rake_spec.rb
+++ b/spec/tasks/gitlab/db/validate_config_rake_spec.rb
@@ -53,6 +53,18 @@ RSpec.describe 'gitlab:db:validate_config', :silence_stdout do
expect { run_rake_task('gitlab:db:validate_config') }.not_to output(/Database config validation failure/).to_stderr
expect { run_rake_task('gitlab:db:validate_config') }.not_to raise_error
end
+
+ context 'when finding the initializer fails' do
+ where(:raised_error) { [ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished, PG::ConnectionBad] }
+ with_them do
+ it "does not raise an error for #{params[:raised_error]}" do
+ allow(ActiveRecord::Base.connection).to receive(:select_one).and_raise(raised_error) # rubocop: disable Database/MultipleDatabases
+
+ expect { run_rake_task('gitlab:db:validate_config') }.not_to output(/Database config validation failure/).to_stderr
+ expect { run_rake_task('gitlab:db:validate_config') }.not_to raise_error
+ end
+ end
+ end
end
shared_examples 'raises an error' do |match|
diff --git a/spec/tasks/gitlab/setup_rake_spec.rb b/spec/tasks/gitlab/setup_rake_spec.rb
index 6e4d5087517..6b4dde22dca 100644
--- a/spec/tasks/gitlab/setup_rake_spec.rb
+++ b/spec/tasks/gitlab/setup_rake_spec.rb
@@ -22,7 +22,11 @@ RSpec.describe 'gitlab:setup namespace rake tasks', :silence_stdout do
let(:server_service1) { double(:server_service) }
let(:server_service2) { double(:server_service) }
- let(:connections) { Gitlab::Database.database_base_models.values.map(&:connection) }
+ let(:connections) do
+ Gitlab::Database.database_base_models.values.filter_map do |model|
+ model.connection if Gitlab::Database.db_config_share_with(model.connection_db_config).nil?
+ end
+ end
before do
allow(Gitlab).to receive_message_chain('config.repositories.storages').and_return(storages)
@@ -119,6 +123,10 @@ RSpec.describe 'gitlab:setup namespace rake tasks', :silence_stdout do
end
def expect_connections_to_be_terminated
+ expect(Gitlab::Database::EachDatabase).to receive(:each_database_connection)
+ .with(include_shared: false)
+ .and_call_original
+
expect(connections).to all(receive(:execute).with(/SELECT pg_terminate_backend/))
end