Commit 25cac8f4 authored by Stan Hu's avatar Stan Hu

Merge branch 'bw-sha-attribute-geo-fix' into 'master'

raise SecondaryNotConfigured if Geo DB is not found

See merge request gitlab-org/gitlab-ee!6680
parents fbfe390c c022c44a
......@@ -4,6 +4,7 @@ module Geo
class TrackingBase < ActiveRecord::Base
self.abstract_class = true
NOT_CONFIGURED_MSG = 'Geo secondary database is not configured'.freeze
SecondaryNotConfigured = Class.new(StandardError)
if ::Gitlab::Geo.geo_database_configured?
......@@ -12,13 +13,15 @@ module Geo
def self.connection
unless ::Gitlab::Geo.geo_database_configured?
message = 'Geo secondary database is not configured'
message = NOT_CONFIGURED_MSG
message += "\nIn the GDK root, try running `make geo-setup`" if Rails.env.development?
raise SecondaryNotConfigured.new(message)
end
# Don't call super because LoadBalancing::ActiveRecordProxy will intercept it
retrieve_connection
rescue ActiveRecord::NoDatabaseError
raise SecondaryNotConfigured.new(NOT_CONFIGURED_MSG)
end
end
end
---
title: no longer fail when setting up Geo database with GDK
merge_request: 6680
author:
type: fixed
require 'spec_helper'
describe Geo::TrackingBase do
it 'raises when Geo database is not configured' do
allow(Gitlab::Geo).to receive(:geo_database_configured?).and_return(false)
expect(described_class).not_to receive(:retrieve_connection)
expect { described_class.connection }.to raise_error(Geo::TrackingBase::SecondaryNotConfigured)
end
it 'raises when Geo database is not found' do
allow(Gitlab::Geo).to receive(:geo_database_configured?).and_return(true)
allow(described_class).to receive(:retrieve_connection).and_raise(ActiveRecord::NoDatabaseError.new('not found'))
expect(described_class).to receive(:retrieve_connection)
expect { described_class.connection }.to raise_error(Geo::TrackingBase::SecondaryNotConfigured)
end
end
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