Commit 30c323a3 authored by Ash McKenzie's avatar Ash McKenzie

Rename pg_stat_wal_receiver_supported? DB helper

From pg_stat_wal_receiver_supported? to
postgresql_minimum_supported_version?

Also add test coverage
parent 5f5906d8
...@@ -15,7 +15,7 @@ class Admin::Geo::NodesController < Admin::ApplicationController ...@@ -15,7 +15,7 @@ class Admin::Geo::NodesController < Admin::ApplicationController
flash.now[:alert] = _('You need a different license to enable Geo replication.') flash.now[:alert] = _('You need a different license to enable Geo replication.')
end end
unless Gitlab::Database.pg_stat_wal_receiver_supported? unless Gitlab::Database.postgresql_minimum_supported_version?
flash.now[:warning] = _('Please upgrade PostgreSQL to version 9.6 or greater. The status of the replication cannot be determined reliably with the current version.') flash.now[:warning] = _('Please upgrade PostgreSQL to version 9.6 or greater. The status of the replication cannot be determined reliably with the current version.')
end end
end end
......
...@@ -220,7 +220,7 @@ namespace :geo do ...@@ -220,7 +220,7 @@ namespace :geo do
puts GeoNode.current_node_url puts GeoNode.current_node_url
puts '-----------------------------------------------------'.color(:yellow) puts '-----------------------------------------------------'.color(:yellow)
unless Gitlab::Database.pg_stat_wal_receiver_supported? unless Gitlab::Database.postgresql_minimum_supported_version?
puts puts
puts 'WARNING: Please upgrade PostgreSQL to version 9.6 or greater. The status of the replication cannot be determined reliably with the current version.'.color(:red) puts 'WARNING: Please upgrade PostgreSQL to version 9.6 or greater. The status of the replication cannot be determined reliably with the current version.'.color(:red)
puts puts
......
...@@ -65,7 +65,7 @@ describe Admin::Geo::NodesController, :postgresql do ...@@ -65,7 +65,7 @@ describe Admin::Geo::NodesController, :postgresql do
context 'with Postgres 9.6 or greater' do context 'with Postgres 9.6 or greater' do
before do before do
allow(Gitlab::Database).to receive(:pg_stat_wal_receiver_supported?).and_return(true) allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
end end
it_behaves_like 'no flash message', :warning it_behaves_like 'no flash message', :warning
...@@ -73,7 +73,7 @@ describe Admin::Geo::NodesController, :postgresql do ...@@ -73,7 +73,7 @@ describe Admin::Geo::NodesController, :postgresql do
context 'without Postgres 9.6 or greater' do context 'without Postgres 9.6 or greater' do
before do before do
allow(Gitlab::Database).to receive(:pg_stat_wal_receiver_supported?).and_return(false) allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
end end
it_behaves_like 'with flash message', :warning, 'Please upgrade PostgreSQL to version 9.6 or greater.' it_behaves_like 'with flash message', :warning, 'Please upgrade PostgreSQL to version 9.6 or greater.'
......
...@@ -80,7 +80,7 @@ module Gitlab ...@@ -80,7 +80,7 @@ module Gitlab
postgresql? && version.to_f >= 9.4 postgresql? && version.to_f >= 9.4
end end
def self.pg_stat_wal_receiver_supported? def self.postgresql_minimum_supported_version?
postgresql? && version.to_f >= 9.6 postgresql? && version.to_f >= 9.6
end end
......
...@@ -87,6 +87,38 @@ describe Gitlab::Database do ...@@ -87,6 +87,38 @@ describe Gitlab::Database do
end end
end end
describe '.postgresql_minimum_supported_version?' do
it 'returns false when not using PostgreSQL' do
allow(described_class).to receive(:postgresql?).and_return(false)
expect(described_class.postgresql_minimum_supported_version?).to eq(false)
end
context 'when using PostgreSQL' do
before do
allow(described_class).to receive(:postgresql?).and_return(true)
end
it 'returns false when using PostgreSQL 9.5' do
allow(described_class).to receive(:version).and_return('9.5')
expect(described_class.postgresql_minimum_supported_version?).to eq(false)
end
it 'returns true when using PostgreSQL 9.6' do
allow(described_class).to receive(:version).and_return('9.6')
expect(described_class.postgresql_minimum_supported_version?).to eq(true)
end
it 'returns true when using PostgreSQL 10 or newer' do
allow(described_class).to receive(:version).and_return('10')
expect(described_class.postgresql_minimum_supported_version?).to eq(true)
end
end
end
describe '.join_lateral_supported?' do describe '.join_lateral_supported?' do
it 'returns false when using MySQL' do it 'returns false when using MySQL' do
allow(described_class).to receive(:postgresql?).and_return(false) allow(described_class).to receive(:postgresql?).and_return(false)
......
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