Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
45 lines
1.8 KiB
Python
45 lines
1.8 KiB
Python
from typing_extensions import override
|
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
class OpensearchHookTests(WebhookTestCase):
|
|
TOPIC_NAME = "OpenSearch alerts"
|
|
|
|
@override
|
|
def setUp(self) -> None:
|
|
super().setUp()
|
|
self.url = self.build_webhook_url()
|
|
|
|
@override
|
|
def get_body(self, fixture_name: str) -> str:
|
|
body = self.webhook_fixture_data(self.webhook_dir_name, fixture_name, file_type="txt")
|
|
return body
|
|
|
|
def test_test_notification_from_channel(self) -> None:
|
|
"""
|
|
Tests the message template that OpenSearch uses for
|
|
test-notifications when setting up the webhook.
|
|
"""
|
|
message = "Test message content body for config id Uz5bK5UBeE4fYdADfbg0"
|
|
self.check_webhook("test_notification", self.TOPIC_NAME, message, content_type="text/plain")
|
|
|
|
def test_test_notification_from_monitor_action(self) -> None:
|
|
"""Tests the default message template provided by OpenSearch."""
|
|
message = (
|
|
"Monitor Storage size monitor just entered alert status. Please investigate the issue.\n"
|
|
"- Trigger: Storage size over 1TB\n"
|
|
"- Severity: 1\n"
|
|
"- Period start: 2025-02-25T00:58:39.607Z\n"
|
|
"- Period end: 2025-02-25T00:59:39.607Z"
|
|
)
|
|
self.check_webhook("default_template", self.TOPIC_NAME, message, content_type="text/plain")
|
|
|
|
def test_example_template_notification(self) -> None:
|
|
"""
|
|
Tests the copyable example message template we provide in the integration documentation.
|
|
"""
|
|
message = "Alert of severity **3** triggered by **Insufficient memory**."
|
|
expected_topic = "Resource Monitor"
|
|
self.check_webhook("example_template", expected_topic, message, content_type="text/plain")
|