summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/load_balancing/service_discovery_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/database/load_balancing/service_discovery_spec.rb')
-rw-r--r--spec/lib/gitlab/database/load_balancing/service_discovery_spec.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/spec/lib/gitlab/database/load_balancing/service_discovery_spec.rb b/spec/lib/gitlab/database/load_balancing/service_discovery_spec.rb
index bfd9c644ffa..9a559c7ccb4 100644
--- a/spec/lib/gitlab/database/load_balancing/service_discovery_spec.rb
+++ b/spec/lib/gitlab/database/load_balancing/service_discovery_spec.rb
@@ -90,7 +90,7 @@ RSpec.describe Gitlab::Database::LoadBalancing::ServiceDiscovery, feature_catego
end
end
- context 'with failures' do
+ context 'with StandardError' do
before do
allow(Gitlab::ErrorTracking).to receive(:track_exception)
allow(service).to receive(:sleep)
@@ -142,6 +142,21 @@ RSpec.describe Gitlab::Database::LoadBalancing::ServiceDiscovery, feature_catego
service.perform_service_discovery
end
end
+
+ context 'with Exception' do
+ it 'logs error and re-raises the exception' do
+ error = Exception.new('uncaught-test-error')
+
+ expect(service).to receive(:refresh_if_necessary).and_raise(error)
+
+ expect(Gitlab::Database::LoadBalancing::Logger).to receive(:error).with(
+ event: :service_discovery_unexpected_exception,
+ message: "Service discovery encountered an uncaught error: uncaught-test-error"
+ )
+
+ expect { service.perform_service_discovery }.to raise_error(Exception, error.message)
+ end
+ end
end
describe '#refresh_if_necessary' do