Commit 1463201f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ab-remove-postgresql-switches' into 'master'

Further remove code branches by database type (EE)

See merge request gitlab-org/gitlab-ee!14824
parents 790671ed 7ee21e15
......@@ -6,7 +6,6 @@ class UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform
return unless ::Gitlab::Database.postgresql?
return if ::Gitlab::Database.read_only?
return unless ::Gitlab::CurrentSettings.should_check_namespace_plan?
......
......@@ -85,7 +85,6 @@ module Gitlab
def self.enable?
return false unless ::License.feature_available?(:db_load_balancing)
return false if program_name == 'rake' || Sidekiq.server?
return false unless Database.postgresql?
hosts.any? || service_discovery_enabled?
end
......
......@@ -6,8 +6,6 @@ module Gitlab
include Gitlab::Utils::StrongMemoize
def perform_checks
raise NotImplementedError.new('Geo is only compatible with PostgreSQL') unless Gitlab::Database.postgresql?
return '' unless Gitlab::Geo.secondary?
return 'Geo database configuration file is missing.' unless Gitlab::Geo.geo_database_configured?
return 'Geo node has a database that is writable which is an indication it is not configured for replication with the primary node.' unless Gitlab::Database.db_read_only?
......
......@@ -124,14 +124,12 @@ describe Gitlab::Database::LoadBalancing::Host do
expect(host).not_to be_online
end
if Gitlab::Database.postgresql?
it 'returns false when PG::Error is raised' do
allow(host)
.to receive(:check_replica_status?)
.and_raise(PG::Error)
it 'returns false when PG::Error is raised' do
allow(host)
.to receive(:check_replica_status?)
.and_raise(PG::Error)
expect(host).not_to be_online
end
expect(host).not_to be_online
end
end
end
......
......@@ -156,10 +156,8 @@ describe Gitlab::Database::LoadBalancing::LoadBalancer do
end
describe '#primary_write_location' do
if Gitlab::Database.postgresql?
it 'returns a String' do
expect(lb.primary_write_location).to be_an_instance_of(String)
end
it 'returns a String' do
expect(lb.primary_write_location).to be_an_instance_of(String)
end
it 'raises an error if the write location could not be retrieved' do
......
......@@ -120,14 +120,6 @@ describe Gitlab::Database::LoadBalancing do
expect(described_class.enable?).to eq(false)
end
it 'returns false when a database other than PostgreSQL is being used' do
allow(described_class).to receive(:hosts).and_return(%w(foo))
allow(Sidekiq).to receive(:server?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(described_class.enable?).to eq(false)
end
it 'returns false when running inside a Rake task' do
expect(described_class).to receive(:program_name).and_return('rake')
......@@ -137,7 +129,6 @@ describe Gitlab::Database::LoadBalancing do
it 'returns true when load balancing should be enabled' do
allow(described_class).to receive(:hosts).and_return(%w(foo))
allow(Sidekiq).to receive(:server?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(described_class.enable?).to eq(true)
end
......@@ -145,7 +136,6 @@ describe Gitlab::Database::LoadBalancing do
it 'returns true when service discovery is enabled' do
allow(described_class).to receive(:hosts).and_return([])
allow(Sidekiq).to receive(:server?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
allow(described_class)
.to receive(:service_discovery_enabled?)
......@@ -178,7 +168,6 @@ describe Gitlab::Database::LoadBalancing do
it 'is enabled' do
allow(described_class).to receive(:hosts).and_return(%w(foo))
allow(Sidekiq).to receive(:server?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(described_class.enable?).to eq(true)
end
......
......@@ -13,25 +13,13 @@ describe Gitlab::Geo::HealthCheck, :geo do
context 'when an exception is raised' do
it 'catches the exception nicely and returns the message' do
allow(Gitlab::Database).to receive(:postgresql?).and_raise('Uh oh')
allow(Gitlab::Geo).to receive(:secondary?).and_raise('Uh oh')
expect(subject.perform_checks).to eq('Uh oh')
end
end
context 'without PostgreSQL' do
it 'raises an error' do
allow(Gitlab::Database).to receive(:postgresql?) { false }
expect { subject.perform_checks }.to raise_error(NotImplementedError)
end
end
context 'with PostgreSQL' do
before do
allow(Gitlab::Database).to receive(:postgresql?) { true }
end
context 'on the primary node' do
it 'returns an empty string' do
allow(Gitlab::Geo).to receive(:secondary?) { false }
......
......@@ -19,10 +19,6 @@ RSpec.configure do |config|
TestLicense.init
end
config.around(:each, :geo) do |example|
example.run if Gitlab::Database.postgresql?
end
config.around(:each, :geo_tracking_db) do |example|
example.run if Gitlab::Geo.geo_database_configured?
end
......
......@@ -9,12 +9,10 @@ describe UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker do
let!(:early_adopter_plan) { create(:early_adopter_plan) }
let!(:gitlab_subscription) { create(:gitlab_subscription, namespace: group) }
let(:db_is_postgres) { true }
let(:db_is_read_only) { false }
let(:subscription_attrs) { nil }
before do
allow(Gitlab::Database).to receive(:postgresql?) { db_is_postgres }
allow(Gitlab::Database).to receive(:read_only?) { db_is_read_only }
allow(Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?) { true }
......@@ -27,12 +25,6 @@ describe UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker do
end
end
context 'when the DB is not PostgreSQL' do
let(:db_is_postgres) { false }
include_examples 'keeps original max_seats_used value'
end
context 'where the DB is read only' do
let(:db_is_read_only) { true }
......
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