Commit e7b5a68d authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@13-3-stable-ee

parent c8fb2e6a
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
return this.actions.length > 0; return this.actions.length > 0;
}, },
hasValidBlobs() { hasValidBlobs() {
return this.actions.every(x => x.filePath && x.content); return this.actions.every(x => x.content);
}, },
updatePrevented() { updatePrevented() {
return this.snippet.title === '' || !this.hasValidBlobs || this.isUpdating; return this.snippet.title === '' || !this.hasValidBlobs || this.isUpdating;
......
...@@ -123,7 +123,7 @@ class GroupsController < Groups::ApplicationController ...@@ -123,7 +123,7 @@ class GroupsController < Groups::ApplicationController
if Groups::UpdateService.new(@group, current_user, group_params).execute if Groups::UpdateService.new(@group, current_user, group_params).execute
redirect_to edit_group_path(@group, anchor: params[:update_section]), notice: "Group '#{@group.name}' was successfully updated." redirect_to edit_group_path(@group, anchor: params[:update_section]), notice: "Group '#{@group.name}' was successfully updated."
else else
@group.path = @group.path_before_last_save || @group.path_was @group.reset
render action: "edit" render action: "edit"
end end
end end
......
...@@ -7,7 +7,21 @@ module Resolvers ...@@ -7,7 +7,21 @@ module Resolvers
type Types::IssueStatusCountsType, null: true type Types::IssueStatusCountsType, null: true
def continue_issue_resolve(parent, finder, **args) def continue_issue_resolve(parent, finder, **args)
finder.params[parent_param(parent)] = parent if parent
Gitlab::IssuablesCountForState.new(finder, parent) Gitlab::IssuablesCountForState.new(finder, parent)
end end
private
def parent_param(parent)
case parent
when Project
:project_id
when Group
:group_id
else
raise "Unexpected type of parent: #{parent.class}. Must be Project or Group"
end
end
end end
end end
---
title: Scope incident issue counts by given project or group
merge_request: 40700
author:
type: fixed
---
title: Fix snippet save button disabled with empty file path
merge_request: 40412
author:
type: fixed
---
title: Fix race condition in concurrent backups
merge_request: 39894
author:
type: fixed
---
title: Display upcoming database deprecation warning only if current database version minimum is not met
merge_request: 38225
author:
type: removed
---
title: Prevent accidental group deletion if path rename fails
merge_request: 40353
author:
type: fixed
---
title: Fix exception handling when a concurrent backup fails
merge_request: 40451
author:
type: fixed
...@@ -940,6 +940,9 @@ cluster. ...@@ -940,6 +940,9 @@ cluster.
## Distributed reads ## Distributed reads
> - Introduced in GitLab 13.1 in [beta](https://about.gitlab.com/handbook/product/gitlab-the-product/#alpha-beta-ga) with feature flag `gitaly_distributed_reads` set to disabled.
> - [Made generally available](https://gitlab.com/gitlab-org/gitaly/-/issues/2951) in GitLab 13.3.
Praefect supports distribution of read operations across Gitaly nodes that are Praefect supports distribution of read operations across Gitaly nodes that are
configured for the virtual node. configured for the virtual node.
......
...@@ -744,7 +744,11 @@ so `&&` is evaluated before `||`. ...@@ -744,7 +744,11 @@ so `&&` is evaluated before `||`.
#### Parentheses #### Parentheses
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3 > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3
> - It's deployed behind a feature flag, enabled by default.
> - It's enabled on GitLab.com.
> - It's recommended for production use.
> - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#enable-or-disable-parenthesis-support-for-variables-core-only). **(CORE ONLY)**
It is possible to use parentheses to group conditions. Parentheses have the highest It is possible to use parentheses to group conditions. Parentheses have the highest
precedence of all operators. Expressions enclosed in parentheses are evaluated first, precedence of all operators. Expressions enclosed in parentheses are evaluated first,
...@@ -760,20 +764,22 @@ Examples: ...@@ -760,20 +764,22 @@ Examples:
- `($VARIABLE1 =~ /^content.*/ || $VARIABLE2 =~ /thing$/) && $VARIABLE3` - `($VARIABLE1 =~ /^content.*/ || $VARIABLE2 =~ /thing$/) && $VARIABLE3`
- `$CI_COMMIT_BRANCH == "my-branch" || (($VARIABLE1 == "thing" || $VARIABLE2 == "thing") && $VARIABLE3)` - `$CI_COMMIT_BRANCH == "my-branch" || (($VARIABLE1 == "thing" || $VARIABLE2 == "thing") && $VARIABLE3)`
##### Enable or disable parenthesis support for variables **(CORE ONLY)**
The feature is currently deployed behind a feature flag that is **enabled by default**. The feature is currently deployed behind a feature flag that is **enabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md) [GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can opt to disable it for your instance. can opt to disable it for your instance.
To enable it: To disable it:
```ruby ```ruby
Feature.enable(:ci_if_parenthesis_enabled) Feature.disable(:ci_if_parenthesis_enabled)
``` ```
To disable it: To enable it:
```ruby ```ruby
Feature.disable(:ci_if_parenthesis_enabled) Feature.enable(:ci_if_parenthesis_enabled)
``` ```
### Storing regular expressions in variables ### Storing regular expressions in variables
......
...@@ -1548,6 +1548,22 @@ considered for their usage and behavior in this context. Future keyword improvem ...@@ -1548,6 +1548,22 @@ considered for their usage and behavior in this context. Future keyword improvem
are being discussed in our [epic for improving `rules`](https://gitlab.com/groups/gitlab-org/-/epics/2783), are being discussed in our [epic for improving `rules`](https://gitlab.com/groups/gitlab-org/-/epics/2783),
where anyone can add suggestions or requests. where anyone can add suggestions or requests.
You can use [parentheses](../variables/README.md#parentheses) with `&&` and `||` to build more complicated variable expressions.
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3:
```yaml
job1:
script:
- echo This rule uses parentheses.
rules:
if: ($CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "develop") && $MY_VARIABLE
```
NOTE: **Note:**
In GitLab 13.2 and older, the order of operations when mixing `||` and `&&` in a single rule may not have executed
in the expected order. This is [fixed](https://gitlab.com/gitlab-org/gitlab/-/issues/230938)
in GitLab 13.3.
### `only`/`except` (basic) ### `only`/`except` (basic)
NOTE: **Note:** NOTE: **Note:**
...@@ -1833,7 +1849,17 @@ end-to-end: ...@@ -1833,7 +1849,17 @@ end-to-end:
- $CI_COMMIT_MESSAGE =~ /skip-end-to-end-tests/ - $CI_COMMIT_MESSAGE =~ /skip-end-to-end-tests/
``` ```
Learn more about [variables expressions](../variables/README.md#environment-variables-expressions). You can use [parentheses](../variables/README.md#parentheses) with `&&` and `||` to build more complicated variable expressions.
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/230938) in GitLab 13.3:
```yaml
job1:
script:
- echo This rule uses parentheses.
only:
variables:
- ($CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "develop") && $MY_VARIABLE
```
#### `only:changes`/`except:changes` #### `only:changes`/`except:changes`
......
...@@ -11,7 +11,7 @@ as the hardware requirements that are needed to install and use GitLab. ...@@ -11,7 +11,7 @@ as the hardware requirements that are needed to install and use GitLab.
### Supported Linux distributions ### Supported Linux distributions
- Ubuntu (16.04/18.04) - Ubuntu (16.04/18.04/20.04)
- Debian (8/9/10) - Debian (8/9/10)
- CentOS (6/7/8) - CentOS (6/7/8)
- openSUSE (Leap 15.1/Enterprise Server 12.2) - openSUSE (Leap 15.1/Enterprise Server 12.2)
......
...@@ -26,13 +26,17 @@ module Backup ...@@ -26,13 +26,17 @@ module Backup
threads = Gitlab.config.repositories.storages.keys.map do |storage| threads = Gitlab.config.repositories.storages.keys.map do |storage|
Thread.new do Thread.new do
Rails.application.executor.wrap do
dump_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency) dump_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency)
rescue => e rescue => e
errors << e errors << e
end end
end end
end
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
threads.each(&:join) threads.each(&:join)
end
raise errors.pop unless errors.empty? raise errors.pop unless errors.empty?
end end
...@@ -155,6 +159,7 @@ module Backup ...@@ -155,6 +159,7 @@ module Backup
threads = Array.new(max_storage_concurrency) do threads = Array.new(max_storage_concurrency) do
Thread.new do Thread.new do
Rails.application.executor.wrap do
while project = queue.pop while project = queue.pop
semaphore.acquire semaphore.acquire
...@@ -169,6 +174,7 @@ module Backup ...@@ -169,6 +174,7 @@ module Backup
end end
end end
end end
end
Project.for_repository_storage(storage).find_each(batch_size: 100) do |project| Project.for_repository_storage(storage).find_each(batch_size: 100) do |project|
break unless errors.empty? break unless errors.empty?
...@@ -176,10 +182,12 @@ module Backup ...@@ -176,10 +182,12 @@ module Backup
queue.push(project) queue.push(project)
end end
raise errors.pop unless errors.empty?
ensure
queue.close queue.close
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
threads.each(&:join) threads.each(&:join)
end
raise errors.pop unless errors.empty?
end end
def dump_project(project) def dump_project(project)
......
...@@ -6,48 +6,21 @@ module Gitlab ...@@ -6,48 +6,21 @@ module Gitlab
extend self extend self
def check def check
notices = [] return [] if Gitlab::Database.postgresql_minimum_supported_version?
unless Gitlab::Database.postgresql_minimum_supported_version? [
string_args = {
pg_version_current: Gitlab::Database.version,
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
pg_requirements_url_open: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">'.html_safe,
pg_requirements_url_close: '</a>'.html_safe
}
notices <<
{ {
type: 'warning', type: 'warning',
message: html_escape(_('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \ message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
'%{pg_version_minimum} is required for this version of GitLab. ' \ '%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \ 'Please upgrade your environment to a supported PostgreSQL version, ' \
'see %{pg_requirements_url_open}database requirements%{pg_requirements_url_close} for details.')) % string_args 'see %{pg_requirements_url} for details.') % {
} pg_version_current: Gitlab::Database.version,
end 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>'
if Gitlab::Database.postgresql_upcoming_deprecation? && Gitlab::Database.within_deprecation_notice_window?
upcoming_deprecation = Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS
string_args = {
pg_version_upcoming: upcoming_deprecation[:pg_version_minimum],
gl_version_upcoming: upcoming_deprecation[:gl_version],
gl_version_upcoming_date: upcoming_deprecation[:gl_version_date],
pg_version_upcoming_url_open: "<a href=\"#{upcoming_deprecation[:url]}\">".html_safe,
pg_version_upcoming_url_close: '</a>'.html_safe
} }
notices <<
{
type: 'warning',
message: html_escape(_('Note that PostgreSQL %{pg_version_upcoming} will become the minimum required ' \
'version in GitLab %{gl_version_upcoming} (%{gl_version_upcoming_date}). Please ' \
'consider upgrading your environment to a supported PostgreSQL version soon, ' \
'see %{pg_version_upcoming_url_open}the related epic%{pg_version_upcoming_url_close} for details.')) % string_args
} }
end ]
notices
end end
end end
end end
......
...@@ -6,20 +6,6 @@ module Gitlab ...@@ -6,20 +6,6 @@ module Gitlab
# https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements # https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements
MINIMUM_POSTGRES_VERSION = 11 MINIMUM_POSTGRES_VERSION = 11
# Upcoming PostgreSQL version requirements
# Allows a soft warning about an upcoming minimum version requirement
# so administrators can prepare to upgrade
UPCOMING_POSTGRES_VERSION_DETAILS = {
gl_version: '13.6.0',
gl_version_date: 'November 22, 2020',
pg_version_minimum: 12,
url: 'https://gitlab.com/groups/gitlab-org/-/epics/2374'
}.freeze
# Specifies the maximum number of days in advance to display a notice
# regarding an upcoming PostgreSQL version deprecation.
DEPRECATION_WINDOW_DAYS = 90
# https://www.postgresql.org/docs/9.2/static/datatype-numeric.html # https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
MAX_INT_VALUE = 2147483647 MAX_INT_VALUE = 2147483647
MIN_INT_VALUE = -2147483648 MIN_INT_VALUE = -2147483648
...@@ -114,22 +100,6 @@ module Gitlab ...@@ -114,22 +100,6 @@ module Gitlab
version.to_f >= MINIMUM_POSTGRES_VERSION version.to_f >= MINIMUM_POSTGRES_VERSION
end end
def self.postgresql_upcoming_deprecation?
version.to_f < UPCOMING_POSTGRES_VERSION_DETAILS[:pg_version_minimum]
end
def self.days_until_deprecation
(
Date.parse(UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) -
Date.today
).to_i
end
private_class_method :days_until_deprecation
def self.within_deprecation_notice_window?
days_until_deprecation <= DEPRECATION_WINDOW_DAYS
end
def self.check_postgres_version_and_print_warning def self.check_postgres_version_and_print_warning
return if Gitlab::Database.postgresql_minimum_supported_version? return if Gitlab::Database.postgresql_minimum_supported_version?
return if Gitlab::Runtime.rails_runner? return if Gitlab::Runtime.rails_runner?
......
...@@ -16610,9 +16610,6 @@ msgstr "" ...@@ -16610,9 +16610,6 @@ msgstr ""
msgid "Note parameters are invalid: %{errors}" msgid "Note parameters are invalid: %{errors}"
msgstr "" msgstr ""
msgid "Note that PostgreSQL %{pg_version_upcoming} will become the minimum required version in GitLab %{gl_version_upcoming} (%{gl_version_upcoming_date}). Please consider upgrading your environment to a supported PostgreSQL version soon, see %{pg_version_upcoming_url_open}the related epic%{pg_version_upcoming_url_close} for details."
msgstr ""
msgid "Note that this invitation was sent to %{mail_to_invite_email}, but you are signed in as %{link_to_current_user} with email %{mail_to_current_user}." msgid "Note that this invitation was sent to %{mail_to_invite_email}, but you are signed in as %{link_to_current_user} with email %{mail_to_current_user}."
msgstr "" msgstr ""
...@@ -27906,7 +27903,7 @@ msgstr "" ...@@ -27906,7 +27903,7 @@ msgstr ""
msgid "You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico." msgid "You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico."
msgstr "" msgstr ""
msgid "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_open}database requirements%{pg_requirements_url_close} for details." msgid "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."
msgstr "" msgstr ""
msgid "You can %{linkStart}view the blob%{linkEnd} instead." msgid "You can %{linkStart}view the blob%{linkEnd} instead."
......
...@@ -555,6 +555,21 @@ RSpec.describe GroupsController do ...@@ -555,6 +555,21 @@ RSpec.describe GroupsController do
end end
end end
context 'when there is a conflicting group path' do
render_views
let!(:conflict_group) { create(:group, path: SecureRandom.hex(12) ) }
let!(:old_name) { group.name }
it 'does not render references to the conflicting group' do
put :update, params: { id: group.to_param, group: { path: conflict_group.path } }
expect(response).to have_gitlab_http_status(:ok)
expect(group.reload.name).to eq(old_name)
expect(response.body).not_to include(conflict_group.path)
end
end
context 'when a project inside the group has container repositories' do context 'when a project inside the group has container repositories' do
before do before do
stub_container_registry_config(enabled: true) stub_container_registry_config(enabled: true)
......
...@@ -179,7 +179,7 @@ describe('Snippet Edit app', () => { ...@@ -179,7 +179,7 @@ describe('Snippet Edit app', () => {
${'foo'} | ${[]} | ${false} ${'foo'} | ${[]} | ${false}
${'foo'} | ${[TEST_ACTIONS.VALID]} | ${false} ${'foo'} | ${[TEST_ACTIONS.VALID]} | ${false}
${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_CONTENT]} | ${true} ${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_CONTENT]} | ${true}
${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_PATH]} | ${true} ${'foo'} | ${[TEST_ACTIONS.VALID, TEST_ACTIONS.NO_PATH]} | ${false}
`( `(
'should handle submit disable (title=$title, actions=$actions, shouldDisable=$shouldDisable)', 'should handle submit disable (title=$title, actions=$actions, shouldDisable=$shouldDisable)',
async ({ title, actions, shouldDisable }) => { async ({ title, actions, shouldDisable }) => {
......
...@@ -7,14 +7,21 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do ...@@ -7,14 +7,21 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
describe '#resolve' do describe '#resolve' do
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) } let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:issue) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) } let_it_be(:issue) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
let_it_be(:incident) { create(:incident, project: project, state: :closed, created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) } let_it_be(:incident) { create(:incident, project: project, state: :closed, created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
# This issue should not be included in the counts
let_it_be(:other_project) { create(:project) }
let_it_be(:other_proj_issue) { create(:issue, state: :opened, project: other_project) }
let(:parent) { project }
let(:args) { {} } let(:args) { {} }
before do before_all do
project.add_developer(current_user) project.add_developer(current_user)
other_project.add_developer(current_user)
end end
subject { resolve_issue_status_counts(args) } subject { resolve_issue_status_counts(args) }
...@@ -22,13 +29,23 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do ...@@ -22,13 +29,23 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
it { is_expected.to be_a(Gitlab::IssuablesCountForState) } it { is_expected.to be_a(Gitlab::IssuablesCountForState) }
specify { expect(subject.project).to eq(project) } specify { expect(subject.project).to eq(project) }
it 'returns expected results' do shared_examples 'returns expected results' do
it 'returns expected results', :aggregate_failures do
result = resolve_issue_status_counts result = resolve_issue_status_counts
expect(result.all).to eq 2 expect(result.all).to eq 2
expect(result.opened).to eq 1 expect(result.opened).to eq 1
expect(result.closed).to eq 1 expect(result.closed).to eq 1
end end
end
it_behaves_like 'returns expected results'
context 'group used as parent' do
let(:parent) { project.group }
it_behaves_like 'returns expected results'
end
it 'filters by search', :aggregate_failures do it 'filters by search', :aggregate_failures do
result = resolve_issue_status_counts(search: issue.title) result = resolve_issue_status_counts(search: issue.title)
...@@ -58,7 +75,7 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do ...@@ -58,7 +75,7 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
private private
def resolve_issue_status_counts(args = {}, context = { current_user: current_user }) def resolve_issue_status_counts(args = {}, context = { current_user: current_user })
resolve(described_class, obj: project, args: args, ctx: context) resolve(described_class, obj: parent, args: args, ctx: context)
end end
end end
end end
...@@ -55,7 +55,7 @@ RSpec.describe Backup::Repository do ...@@ -55,7 +55,7 @@ RSpec.describe Backup::Repository do
end end
[4, 10].each do |max_storage_concurrency| [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 it 'creates the expected number of threads' do
expect(Thread).to receive(:new) expect(Thread).to receive(:new)
.exactly(storage_keys.length * (max_storage_concurrency + 1)).times .exactly(storage_keys.length * (max_storage_concurrency + 1)).times
......
...@@ -6,84 +6,35 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do ...@@ -6,84 +6,35 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do
describe '#check' do describe '#check' do
subject { described_class.check } subject { described_class.check }
let_it_be(:deprecation_warning) { "Please upgrade" } context 'when database meets minimum supported version' do
let_it_be(:upcoming_deprecation_warning) { "Please consider upgrading" }
context 'when database meets minimum version and there is no upcoming deprecation' do
before do before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true) allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
end end
it { is_expected.to be_empty } it { is_expected.to be_empty }
end 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 before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false) allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
end end
it 'only returns notice about deprecated database version' do let(:notice_deprecated_database) 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))) type: 'warning',
end message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
end '%{pg_version_minimum} is required for this version of GitLab. ' \
'Please upgrade your environment to a supported PostgreSQL version, ' \
context 'when database meets minimum version and there is an upcoming deprecation' do 'see %{pg_requirements_url} for details.') % {
before do pg_version_current: Gitlab::Database.version,
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true) pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true) 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 end
it 'only returns notice about an upcoming deprecation' do it 'reports deprecated database notice' do
is_expected.to include(a_hash_including(message: include(upcoming_deprecation_warning))) is_expected.to contain_exactly(notice_deprecated_database)
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
end end
end end
end end
......
...@@ -109,46 +109,6 @@ RSpec.describe Gitlab::Database do ...@@ -109,46 +109,6 @@ RSpec.describe Gitlab::Database do
end end
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 describe '.check_postgres_version_and_print_warning' do
subject { described_class.check_postgres_version_and_print_warning } subject { described_class.check_postgres_version_and_print_warning }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment