Commit 9babc9f7 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Stan Hu

Fix FDW check when Geo secondary database is not configured

parent 57afb276
...@@ -62,6 +62,8 @@ module Gitlab ...@@ -62,6 +62,8 @@ module Gitlab
def fdw_capable? def fdw_capable?
has_foreign_server? && has_foreign_schema? && foreign_schema_tables_count.positive? has_foreign_server? && has_foreign_schema? && foreign_schema_tables_count.positive?
rescue ::Geo::TrackingBase::SecondaryNotConfigured
false
end end
# Check if there is at least one foreign server configured # Check if there is at least one foreign server configured
......
...@@ -2,6 +2,12 @@ require 'spec_helper' ...@@ -2,6 +2,12 @@ require 'spec_helper'
describe Gitlab::Geo::Fdw, :geo do describe Gitlab::Geo::Fdw, :geo do
describe '.enabled?' do describe '.enabled?' do
it 'returns false when Geo secondary database is not configured' do
allow(Gitlab::Geo).to receive(:geo_database_configured?).and_return(false)
expect(described_class.enabled?).to eq false
end
it 'returns false when foreign server does not exist' do it 'returns false when foreign server does not exist' do
drop_foreign_server drop_foreign_server
...@@ -44,7 +50,7 @@ describe Gitlab::Geo::Fdw, :geo do ...@@ -44,7 +50,7 @@ describe Gitlab::Geo::Fdw, :geo do
end end
end end
describe '.enabled?' do describe '.disabled?' do
it 'returns true when foreign server does not exist' do it 'returns true when foreign server does not exist' do
drop_foreign_server drop_foreign_server
...@@ -70,6 +76,12 @@ describe Gitlab::Geo::Fdw, :geo do ...@@ -70,6 +76,12 @@ describe Gitlab::Geo::Fdw, :geo do
expect(described_class.disabled?).to eq true expect(described_class.disabled?).to eq true
end end
it 'returns true when Geo secondary database is not configured' do
allow(Gitlab::Geo).to receive(:geo_database_configured?).and_return(false)
expect(described_class.disabled?).to eq true
end
it 'returns false when fdw is set in `config/database_geo.yml`' do it 'returns false when fdw is set in `config/database_geo.yml`' do
allow(Rails.configuration).to receive(:geo_database).and_return('fdw' => true) allow(Rails.configuration).to receive(:geo_database).and_return('fdw' => 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