diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-28 13:14:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-28 13:14:44 +0000 |
commit | e7b5a68daecd0aff0cc66666cb38c7971027a05a (patch) | |
tree | b153db785557cc807da5e623cb130a1ef384926e /spec/lib | |
parent | c8fb2e6a3942330079bde06d919cd33c6bc7600e (diff) | |
download | gitlab-ce-e7b5a68daecd0aff0cc66666cb38c7971027a05a.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/backup/repository_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/config_checker/external_database_checker_spec.rb | 81 | ||||
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 40 |
3 files changed, 17 insertions, 106 deletions
diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index fef5e018231..c4ad239f9d7 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -55,7 +55,7 @@ RSpec.describe Backup::Repository do end [4, 10].each do |max_storage_concurrency| - context "max_storage_concurrency #{max_storage_concurrency}" do + context "max_storage_concurrency #{max_storage_concurrency}", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/241701' do it 'creates the expected number of threads' do expect(Thread).to receive(:new) .exactly(storage_keys.length * (max_storage_concurrency + 1)).times diff --git a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb index 712903e020a..85bafc77553 100644 --- a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb +++ b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb @@ -6,84 +6,35 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do describe '#check' do subject { described_class.check } - let_it_be(:deprecation_warning) { "Please upgrade" } - let_it_be(:upcoming_deprecation_warning) { "Please consider upgrading" } - - context 'when database meets minimum version and there is no upcoming deprecation' do + context 'when database meets minimum supported version' do before do allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false) end it { is_expected.to be_empty } end - context 'when database does not meet minimum version and there is no upcoming deprecation' do + context 'when database does not meet minimum supported version' do before do allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false) - end - - it 'only returns notice about deprecated database version' do - is_expected.to include(a_hash_including(message: include(deprecation_warning))) - is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning))) end - end - context 'when database meets minimum version and there is an upcoming deprecation' do - before do - allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true) + let(:notice_deprecated_database) do + { + type: 'warning', + message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \ + '%{pg_version_minimum} is required for this version of GitLab. ' \ + 'Please upgrade your environment to a supported PostgreSQL version, ' \ + 'see %{pg_requirements_url} for details.') % { + pg_version_current: Gitlab::Database.version, + pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION, + pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>' + } + } end - context 'inside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true) - end - - it 'only returns notice about an upcoming deprecation' do - is_expected.to include(a_hash_including(message: include(upcoming_deprecation_warning))) - is_expected.not_to include(a_hash_including(message: include(deprecation_warning))) - end - end - - context 'outside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false) - end - - it { is_expected.to be_empty } - end - end - - context 'when database does not meet minimum version and there is an upcoming deprecation' do - before do - allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false) - allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true) - end - - context 'inside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true) - end - - it 'returns notice about deprecated database version and an upcoming deprecation' do - is_expected.to include( - a_hash_including(message: include(deprecation_warning)), - a_hash_including(message: include(upcoming_deprecation_warning)) - ) - end - end - - context 'outside the deprecation notice window' do - before do - allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false) - end - - it 'only returns notice about deprecated database version' do - is_expected.to include(a_hash_including(message: include(deprecation_warning))) - is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning))) - end + it 'reports deprecated database notice' do + is_expected.to contain_exactly(notice_deprecated_database) end end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 47d2cb05240..420aa0a8df6 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -109,46 +109,6 @@ RSpec.describe Gitlab::Database do end end - describe '.postgresql_upcoming_deprecation?' do - it 'returns true when database version is lower than the upcoming minimum' do - allow(described_class).to receive(:version).and_return('11') - - expect(described_class.postgresql_upcoming_deprecation?).to eq(true) - end - - it 'returns false when database version equals the upcoming minimum' do - allow(described_class).to receive(:version).and_return('12') - - expect(described_class.postgresql_upcoming_deprecation?).to eq(false) - end - - it 'returns false when database version is greater the upcoming minimum' do - allow(described_class).to receive(:version).and_return('13') - - expect(described_class.postgresql_upcoming_deprecation?).to eq(false) - end - end - - describe '.within_deprecation_notice_window?' do - using RSpec::Parameterized::TableSyntax - - where(:case_name, :days, :result) do - 'outside window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS + 1 | false - 'equal to window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS | true - 'within window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS - 1 | true - end - - with_them do - it "returns #{params[:result]} when #{params[:case_name]}" do - allow(Date) - .to receive(:today) - .and_return Date.parse(Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) - days - - expect(described_class.within_deprecation_notice_window?).to eq(result) - end - end - end - describe '.check_postgres_version_and_print_warning' do subject { described_class.check_postgres_version_and_print_warning } |