Skip to content

Commit

Permalink
Merge pull request #1776 from DFE-Digital/dfe-healthcheck-timeouts
Browse files Browse the repository at this point in the history
Rescue timeouts when health checking Redis
  • Loading branch information
leoapost authored Jun 18, 2021
2 parents b51b769 + 141e868 commit e5ca4da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/healthcheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_redis
return nil unless ENV["REDIS_URL"]

Redis.current.ping == "PONG"
rescue RuntimeError
rescue RuntimeError, Errno::ETIMEDOUT
false
end

Expand Down
9 changes: 5 additions & 4 deletions spec/models/healthcheck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@
end

context "with broken connection" do
before do
allow(Redis).to receive(:current).and_raise Redis::CannotConnectError
it "returns false" do
[Errno::ETIMEDOUT, Redis::CannotConnectError].each do |error|
allow(Redis).to receive(:current).and_raise error
expect(subject).to be false
end
end

it { is_expected.to be false }
end

context 'with non functional redis' do
Expand Down

0 comments on commit e5ca4da

Please sign in to comment.