diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-24 17:28:19 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-24 17:28:19 +0000 |
commit | 0c2b07bfcb884e2b1ab6b5521596423578a3cdf8 (patch) | |
tree | e141bb9c790d02bdcae6d3d66f563c94475a9d51 /spec | |
parent | a77c4d2dce9e77e7104f009822faf56063a37dea (diff) | |
download | gitlab-ce-0c2b07bfcb884e2b1ab6b5521596423578a3cdf8.tar.gz |
Add latest changes from gitlab-org/gitlab@15-5-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/kas/client_spec.rb | 9 | ||||
-rw-r--r-- | spec/support/database/multiple_databases.rb | 20 | ||||
-rw-r--r-- | spec/support/database_cleaner.rb | 10 | ||||
-rw-r--r-- | spec/support/migration.rb | 2 | ||||
-rw-r--r-- | spec/tasks/gitlab/gitaly_rake_spec.rb | 8 |
5 files changed, 31 insertions, 18 deletions
diff --git a/spec/lib/gitlab/kas/client_spec.rb b/spec/lib/gitlab/kas/client_spec.rb index 5b89023cc13..9a0fa6c4067 100644 --- a/spec/lib/gitlab/kas/client_spec.rb +++ b/spec/lib/gitlab/kas/client_spec.rb @@ -111,11 +111,16 @@ RSpec.describe Gitlab::Kas::Client do describe 'with grpcs' do let(:stub) { instance_double(Gitlab::Agent::ConfigurationProject::Rpc::ConfigurationProject::Stub) } + let(:credentials) { instance_double(GRPC::Core::ChannelCredentials) } let(:kas_url) { 'grpcs://example.kas.internal' } - it 'uses a ChannelCredentials object' do + it 'uses a ChannelCredentials object with the correct certificates' do + expect(GRPC::Core::ChannelCredentials).to receive(:new) + .with(Gitlab::X509::Certificate.ca_certs_bundle) + .and_return(credentials) + expect(Gitlab::Agent::ConfigurationProject::Rpc::ConfigurationProject::Stub).to receive(:new) - .with('example.kas.internal', instance_of(GRPC::Core::ChannelCredentials), timeout: described_class::TIMEOUT) + .with('example.kas.internal', credentials, timeout: described_class::TIMEOUT) .and_return(stub) allow(stub).to receive(:list_agent_config_files) diff --git a/spec/support/database/multiple_databases.rb b/spec/support/database/multiple_databases.rb index b863767b5df..b6341c2caec 100644 --- a/spec/support/database/multiple_databases.rb +++ b/spec/support/database/multiple_databases.rb @@ -2,15 +2,6 @@ module Database module MultipleDatabases - def run_and_cleanup(example) - # Each example may call `migrate!`, so we must ensure we are migrated down every time - schema_migrate_down! - - example.run - - delete_from_all_tables!(except: deletion_except_tables) - end - def skip_if_multiple_databases_not_setup skip 'Skipping because multiple databases not set up' unless Gitlab::Database.has_config?(:ci) end @@ -40,10 +31,15 @@ module Database config_model: base_model ) - schema_migrate_up! delete_from_all_tables!(except: deletion_except_tables) + schema_migrate_up! end end + + # ActiveRecord::Base.clear_all_connections! disconnects and clears attribute methods + # Force a refresh to avoid schema failures. + reset_column_in_all_models + refresh_attribute_methods end # The usage of this method switches temporarily used `connection_handler` @@ -152,10 +148,10 @@ RSpec.configure do |config| config_model: base_model ) - run_and_cleanup(example) + example.run end else - run_and_cleanup(example) + example.run end self.class.use_transactional_tests = true diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 7bd1f0c5dfa..222cbe9feeb 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -22,4 +22,14 @@ RSpec.configure do |config| self.class.use_transactional_tests = true end + + config.around(:each, :migration) do |example| + self.class.use_transactional_tests = false + + example.run + + delete_from_all_tables!(except: deletion_except_tables) + + self.class.use_transactional_tests = true + end end diff --git a/spec/support/migration.rb b/spec/support/migration.rb index 24e2fc2ff31..490aa836d74 100644 --- a/spec/support/migration.rb +++ b/spec/support/migration.rb @@ -19,6 +19,8 @@ RSpec.configure do |config| # Each example may call `migrate!`, so we must ensure we are migrated down every time config.before(:each, :migration) do use_fake_application_settings + + schema_migrate_down! end config.after(:context, :migration) do diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb index e57021f749b..d2f4fa0b8ef 100644 --- a/spec/tasks/gitlab/gitaly_rake_spec.rb +++ b/spec/tasks/gitlab/gitaly_rake_spec.rb @@ -66,7 +66,7 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do .with(%w[which gmake]) .and_return(['/usr/bin/gmake', 0]) expect(Gitlab::Popen).to receive(:popen) - .with(%w[gmake clean-build all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }) + .with(%w[gmake clean-build all], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }) .and_return(['ok', 0]) subject @@ -78,7 +78,7 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do .with(%w[which gmake]) .and_return(['/usr/bin/gmake', 0]) expect(Gitlab::Popen).to receive(:popen) - .with(%w[gmake clean-build all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }) + .with(%w[gmake clean-build all], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }) .and_return(['output', 1]) expect { subject }.to raise_error /Gitaly failed to compile: output/ @@ -95,14 +95,14 @@ RSpec.describe 'gitlab:gitaly namespace rake task', :silence_stdout do it 'calls make in the gitaly directory' do expect(Gitlab::Popen).to receive(:popen) - .with(%w[make clean-build all git], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }) + .with(%w[make clean-build all], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }) .and_return(['output', 0]) subject end context 'when Rails.env is test' do - let(:command) { %w[make clean-build all git] } + let(:command) { %w[make clean-build all] } before do stub_rails_env('test') |