mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-01-11 19:38:11 +00:00
Update VictorOps notification template to include failure reason
cc: #1069
This commit is contained in:
parent
dcc5d7a7c4
commit
c28ae32261
3 changed files with 17 additions and 10 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta as td
|
||||
|
@ -38,6 +37,7 @@ class NotifyVictorOpsTestCase(BaseTestCase):
|
|||
self.flip.created = now()
|
||||
self.flip.old_status = "new"
|
||||
self.flip.new_status = "down"
|
||||
self.flip.reason = "timeout"
|
||||
|
||||
@patch("hc.api.transports.curl.request", autospec=True)
|
||||
def test_it_works(self, mock_post: Mock) -> None:
|
||||
|
@ -49,8 +49,18 @@ class NotifyVictorOpsTestCase(BaseTestCase):
|
|||
payload = mock_post.call_args.kwargs["json"]
|
||||
self.assertEqual(payload["message_type"], "CRITICAL")
|
||||
self.assertEqual(payload["entity_id"], self.check.unique_key)
|
||||
self.assertIn("Foo is DOWN.", payload["state_message"])
|
||||
self.assertIn("Last ping was 10 minutes ago.", payload["state_message"])
|
||||
self.assertIn("Foo is DOWN", payload["state_message"])
|
||||
self.assertIn("grace time passed", payload["state_message"])
|
||||
|
||||
@patch("hc.api.transports.curl.request", autospec=True)
|
||||
def test_it_handles_reason_fail(self, mock_post: Mock) -> None:
|
||||
mock_post.return_value.status_code = 200
|
||||
|
||||
self.flip.reason = "fail"
|
||||
self.channel.notify(self.flip)
|
||||
|
||||
payload = mock_post.call_args.kwargs["json"]
|
||||
self.assertIn("received a failure signal", payload["state_message"])
|
||||
|
||||
@override_settings(VICTOROPS_ENABLED=False)
|
||||
def test_it_requires_victorops_enabled(self) -> None:
|
||||
|
@ -70,9 +80,7 @@ class NotifyVictorOpsTestCase(BaseTestCase):
|
|||
self.channel.notify(self.flip)
|
||||
|
||||
payload = mock_post.call_args.kwargs["json"]
|
||||
self.assertEqual(
|
||||
payload["state_message"], "Foo & Bar received a ping and is now UP"
|
||||
)
|
||||
self.assertEqual(payload["state_message"], "Foo & Bar is UP.")
|
||||
|
||||
@patch("hc.api.transports.curl.request", autospec=True)
|
||||
def test_it_does_not_retry_404(self, mock_post: Mock) -> None:
|
||||
|
|
|
@ -823,9 +823,9 @@ class VictorOps(HttpTransport):
|
|||
raise TransportError("Splunk On-Call notifications are not enabled.")
|
||||
|
||||
ctx = {
|
||||
"flip": flip,
|
||||
"check": flip.owner,
|
||||
"status": flip.new_status,
|
||||
"ping": self.last_ping(flip),
|
||||
}
|
||||
mtype = "CRITICAL" if flip.new_status == "down" else "RECOVERY"
|
||||
payload = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{% load humanize %}
|
||||
{% if status == "down" %}
|
||||
{{ check.name_then_code|safe }} is DOWN.
|
||||
{% if ping %}Last ping was {{ ping.created|naturaltime }}.{% endif %}
|
||||
{{ check.name_then_code|safe }} is DOWN{% if flip.reason %} ({{ flip.reason_long }}){% endif %}.
|
||||
{% else %}
|
||||
{{ check.name_then_code|safe }} received a ping and is now UP
|
||||
{{ check.name_then_code|safe }} is UP.
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue