2020-02-07 10:04:22 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class AlertmanagerHookTests(WebhookTestCase):
|
2021-02-12 08:20:45 +01:00
|
|
|
STREAM_NAME = "alertmanager"
|
2020-02-07 10:04:22 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/alertmanager?&api_key={api_key}&stream={stream}&name=topic&desc=description"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "alertmanager"
|
2020-02-07 10:04:22 +01:00
|
|
|
|
|
|
|
def test_error_issue_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "andromeda"
|
2020-02-07 10:04:22 +01:00
|
|
|
expected_message = """
|
|
|
|
:alert: **FIRING**
|
2024-01-30 23:32:41 +01:00
|
|
|
* CPU core temperature is 34.75C ([source](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
|
|
|
|
* CPU core temperature is 17.625C ([source](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
|
2020-02-07 10:04:22 +01:00
|
|
|
""".strip()
|
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2021-02-12 08:19:30 +01:00
|
|
|
"alert",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2021-02-12 08:19:30 +01:00
|
|
|
expected_message,
|
|
|
|
"application/json",
|
2020-02-07 10:04:22 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_single_error_issue_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "andromeda"
|
2020-02-07 10:04:22 +01:00
|
|
|
expected_message = """
|
2024-01-30 23:32:41 +01:00
|
|
|
:squared_ok: **Resolved** CPU core temperature is 34.75C ([source](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
|
2020-02-07 10:04:22 +01:00
|
|
|
""".strip()
|
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2021-02-12 08:19:30 +01:00
|
|
|
"single_alert",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2021-02-12 08:19:30 +01:00
|
|
|
expected_message,
|
|
|
|
"application/json",
|
2020-02-07 10:04:22 +01:00
|
|
|
)
|