diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-27 03:08:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-27 03:08:19 +0300 |
commit | c937ca4f20d47f5cc87300eae29dbb98ad0a956c (patch) | |
tree | 761a8febb2e27f7ac1a04c8f077546125818e546 /spec | |
parent | 972f10aa90a29b400ee84ee66e720ec633102b33 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/runner_upgrade_check_spec.rb | 45 | ||||
-rw-r--r-- | spec/tasks/dev_rake_spec.rb | 7 |
2 files changed, 39 insertions, 13 deletions
diff --git a/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb b/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb index 5dd3968cc4e..3953a1aa81a 100644 --- a/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb +++ b/spec/lib/gitlab/ci/runner_upgrade_check_spec.rb @@ -3,13 +3,17 @@ require 'spec_helper' RSpec.describe Gitlab::Ci::RunnerUpgradeCheck do - include StubVersion using RSpec::Parameterized::TableSyntax describe '#check_runner_upgrade_status' do subject(:result) { described_class.instance.check_runner_upgrade_status(runner_version) } + let(:gitlab_version) { '14.1.1' } + before do + allow(described_class.instance).to receive(:gitlab_version) + .and_return(::Gitlab::VersionInfo.parse(gitlab_version)) + runner_releases_double = instance_double(Gitlab::Ci::RunnerReleases) allow(Gitlab::Ci::RunnerReleases).to receive(:instance).and_return(runner_releases_double) @@ -17,7 +21,7 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck do end context 'with available_runner_releases configured up to 14.1.1' do - let(:available_runner_releases) { %w[13.9.0 13.9.1 13.9.2 13.10.0 13.10.1 14.0.0 14.0.1 14.0.2 14.1.0 14.1.1 14.1.1-rc3] } + let(:available_runner_releases) { %w[13.9.0 13.9.1 13.9.2 13.10.0 13.10.1 14.0.0 14.0.1 14.0.2 14.1.0 14.1.1] } context 'with nil runner_version' do let(:runner_version) { nil } @@ -36,11 +40,7 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck do end context 'with Gitlab::VERSION set to 14.1.123' do - before do - stub_version('14.1.123', 'deadbeef') - - described_class.instance.reset! - end + let(:gitlab_version) { '14.1.123' } context 'with a runner_version that is too recent' do let(:runner_version) { 'v14.2.0' } @@ -52,15 +52,11 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck do end context 'with Gitlab::VERSION set to 14.0.1' do - before do - stub_version('14.0.1', 'deadbeef') - - described_class.instance.reset! - end + let(:gitlab_version) { '14.0.1' } context 'with valid params' do where(:runner_version, :expected_result) do - 'v15.0.0' | :not_available # not available since the GitLab instance is still on 14.x and a major version might be incompatible + 'v15.0.0' | :not_available # not available since the GitLab instance is still on 14.x, a major version might be incompatible, and a patch upgrade is not available 'v14.1.0-rc3' | :recommended # recommended since even though the GitLab instance is still on 14.0.x, there is a patch release (14.1.1) available which might contain security fixes 'v14.1.0~beta.1574.gf6ea9389' | :recommended # suffixes are correctly handled 'v14.1.0/1.1.0' | :recommended # suffixes are correctly handled @@ -85,6 +81,29 @@ RSpec.describe Gitlab::Ci::RunnerUpgradeCheck do end end end + + context 'with Gitlab::VERSION set to 13.9.0' do + let(:gitlab_version) { '13.9.0' } + + context 'with valid params' do + where(:runner_version, :expected_result) do + 'v14.0.0' | :recommended # recommended upgrade since 14.0.2 is available, even though the GitLab instance is still on 13.x and a major version might be incompatible + 'v13.10.1' | :not_available # not available since 13.10.1 is already ahead of GitLab instance version and is the latest patch update for 13.10.x + 'v13.10.0' | :recommended # recommended upgrade since 13.10.1 is available + 'v13.9.2' | :recommended # recommended upgrade since backports are no longer released for this version + 'v13.9.0' | :recommended # recommended upgrade since backports are no longer released for this version + 'v13.8.1' | :recommended # recommended upgrade since build is too old (missing in records) + 'v11.4.1' | :recommended # recommended upgrade since build is too old (missing in records) + end + + with_them do + it 'returns symbol representing expected upgrade status' do + is_expected.to be_a(Symbol) + is_expected.to eq(expected_result) + end + end + end + end end end end diff --git a/spec/tasks/dev_rake_spec.rb b/spec/tasks/dev_rake_spec.rb index fa093db414f..41728faa0e0 100644 --- a/spec/tasks/dev_rake_spec.rb +++ b/spec/tasks/dev_rake_spec.rb @@ -50,6 +50,10 @@ RSpec.describe 'dev rake tasks' do end describe 'terminate_all_connections' do + before do + allow(ActiveRecord::Base).to receive(:clear_all_connections!) + end + 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? @@ -75,6 +79,8 @@ RSpec.describe 'dev rake tasks' do it 'terminates all connections' do expect_connections_to_be_terminated + expect(ActiveRecord::Base).to receive(:clear_all_connections!) + terminate_task end @@ -82,6 +88,7 @@ RSpec.describe 'dev rake tasks' do it 'does not terminate connections' do expect(Rails.env).to receive(:production?).and_return(true) expect_connections_not_to_be_terminated + expect(ActiveRecord::Base).not_to receive(:clear_all_connections!) terminate_task end |