diff options
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/gitlab/db/validate_config_rake_spec.rb | 12 | ||||
-rw-r--r-- | spec/tasks/gitlab/setup_rake_spec.rb | 10 |
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 |