Skip to content

Commit

Permalink
Do not report infinite or NaN sidekiq thresholds in healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
barrucadu committed Sep 26, 2018
1 parent b6b63d9 commit aa20955
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def details
thresholds: {
critical: critical_threshold(queue: name),
warning: warning_threshold(queue: name),
},
}.select { |_, val| !(val.to_f.infinite? || val.to_f.nan?) },
}
end,
}
Expand Down
16 changes: 16 additions & 0 deletions spec/lib/govuk_healthcheck/sidekiq_queue_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@
end
end

context "NaNs and infinities" do
subject { TestQueueCheck.new({ queue: 0 }, Float::INFINITY, Float::NAN) }

it_behaves_like "a healthcheck"

its(:status) { is_expected.to eq(:ok) }
its(:message) { is_expected.to match(/below the critical and warning thresholds/) }
its(:details) do
is_expected.to match(
queues: {
queue: hash_including(value: 0, thresholds: {})
}
)
end
end

class TestQueueCheck < GovukHealthcheck::SidekiqQueueCheck
def initialize(queues, warning_threshold, critical_threshold, name = :test)
@queues = queues
Expand Down

0 comments on commit aa20955

Please sign in to comment.