Files
upstream-mirror 64898b2c79
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
snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
2026-09-15 15:05:30 +05:00

355 lines
12 KiB
Python

from zerver.lib.test_classes import WebhookTestCase
class NewRelicHookTests(WebhookTestCase):
def test_incident_activated_new_default_payload(self) -> None:
expected_topic_name = "zulip_app query result is > 1.0 for 1 minutes on 'Zulip S..."
expected_message = """
:red_circle: **[zulip_app query result is > 1.0 for 1 minutes on 'Zulip Server Low Storage'](https://radar-api.service.newrelic.com/accounts/4420147/issues/c5faa7e6-7b54-402d-af79-f99601e0278c?notifier=WEBHOOK)**
```quote
**Priority**: CRITICAL
**State**: ACTIVATED
**Updated at**: <time:2024-04-22T07:08:28+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `Zulip Server Low Storage`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T03:05:31+00:00>
```
""".strip()
self.check_webhook(
"incident_activated_new_default_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_activated_new_provided_base_payload(self) -> None:
expected_topic_name = "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Sto..."
expected_message = """
:orange_circle: **[PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'](https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK)**
```quote
**Priority**: HIGH
**State**: ACTIVATED
**Updated at**: <time:2024-04-22T07:12:29+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `Storage on Host Exceeded Threshold`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T07:12:29+00:00>
- **Your custom payload**: somedata123
```
""".strip()
self.check_webhook(
"incident_activated_new_provided_base_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_closed_default_payload(self) -> None:
expected_topic_name = "main_app-UBUNTU query result is > 2.0 for 1 minutes on 'H..."
expected_message = """
:red_circle: **[main_app-UBUNTU query result is > 2.0 for 1 minutes on 'High CPU'](https://radar-api.service.newrelic.com/accounts/1/issues/0ea2df1c-adab-45d2-aae0-042b609d2322?notifier=SLACK)**
```quote
**Priority**: CRITICAL
**State**: CLOSED
**Updated at**: <time:2024-04-22T06:17:37+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `High CPU`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T06:16:30+00:00>
```
""".strip()
self.check_webhook(
"incident_closed_default_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_closed_provided_base_payload(self) -> None:
expected_topic_name = "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Sto..."
expected_message = """
:orange_circle: **[PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'](https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK)**
```quote
**Priority**: HIGH
**State**: CLOSED
**Updated at**: <time:2024-04-22T07:15:35+00:00>
**Acknowledged by**: Pieter Cardillo Kwok
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `Storage on Host Exceeded Threshold`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T07:12:29+00:00>
- **Your custom payload**: somedata123
```
""".strip()
self.check_webhook(
"incident_closed_provided_base_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_acknowledged_default_payload(self) -> None:
expected_topic_name = "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Sto..."
expected_message = """
:orange_circle: **[PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'](https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK)**
```quote
**Priority**: HIGH
**State**: ACTIVATED
**Updated at**: <time:2024-04-22T07:14:37+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `Storage on Host Exceeded Threshold`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T07:12:29+00:00>
```
""".strip()
self.check_webhook(
"incident_acknowledged_default_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_acknowledged_provided_base_payload(self) -> None:
expected_topic_name = "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Sto..."
expected_message = """
:orange_circle: **[PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'](https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK)**
```quote
**Priority**: HIGH
**State**: ACTIVATED
**Updated at**: <time:2024-04-22T07:14:37+00:00>
**Acknowledged by**: Pieter Cardillo Kwok
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `Storage on Host Exceeded Threshold`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T07:12:29+00:00>
```
""".strip()
self.check_webhook(
"incident_acknowledged_provided_base_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_created_default_payload(self) -> None:
expected_topic_name = "MAIN-APP-UBUNTU query result is > 2.0 for 1 minutes on 'H..."
expected_message = """
:red_circle: **[MAIN-APP-UBUNTU query result is > 2.0 for 1 minutes on 'High CPU'](https://radar-api.service.newrelic.com/accounts/1/issues/0ea2df1c-adab-45d2-aae0-042b609d2322?notifier=SLACK)**
```quote
**Priority**: CRITICAL
**State**: CREATED
**Updated at**: <time:2024-04-22T06:36:29+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `High CPU`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T06:36:29+00:00>
```
""".strip()
self.check_webhook(
"incident_created_default_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_created_provided_base_payload(self) -> None:
expected_topic_name = "PIETER-UBUNTU query result is > 2.0 for 1 minutes on 'Hig..."
expected_message = """
:red_circle: **[PIETER-UBUNTU query result is > 2.0 for 1 minutes on 'High CPU'](https://radar-api.service.newrelic.com/accounts/1/issues/0ea2df1c-adab-45d2-aae0-042b609d2322?notifier=SLACK)**
```quote
**Priority**: CRITICAL
**State**: CREATED
**Updated at**: <time:2024-04-22T06:36:29+00:00>
**Acknowledged by**: John Doe
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `High CPU`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T06:36:29+00:00>
```
""".strip()
self.check_webhook(
"incident_created_provided_base_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_default_base_with_zulip_custom_fields(self) -> None:
expected_topic_name = "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Sto..."
expected_message = """
:orange_circle: **[PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'](https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK)**
```quote
**Priority**: HIGH
**State**: ACTIVATED
**Updated at**: <time:2024-04-22T07:12:29+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `Storage on Host Exceeded Threshold`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T07:12:29+00:00>
- **Your custom payload**: somedata123
- **Custom status 1**: True
- **Custom list 1**: SSD, 2000, False, None, 13.33
- **Custom field 1**: None
- **Custom field 2**: 9000
```
""".strip()
self.check_webhook(
"incident_default_base_with_zulip_custom_fields",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_provided_base_with_zulip_custom_fields(self) -> None:
expected_topic_name = "main_app-UBUNTU query result is > 2.0 for 1 minutes on 'H..."
expected_message = """
:red_circle: **[main_app-UBUNTU query result is > 2.0 for 1 minutes on 'High CPU'](https://radar-api.service.newrelic.com/accounts/1/issues/0ea2df1c-adab-45d2-aae0-042b609d2322?notifier=SLACK)**
```quote
**Priority**: CRITICAL
**State**: CLOSED
**Updated at**: <time:2024-04-22T06:17:37+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `High CPU`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T06:16:30+00:00>
- **Your custom payload**: somedata123
- **Custom status 1**: True
- **Custom list 1**: SSD, 2000, False, None, 13.33
- **Custom field 1**: None
- **Custom field 2**: 9000
```
""".strip()
self.check_webhook(
"incident_provided_base_with_zulip_custom_fields",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_incident_with_invalid_zulip_custom_fields(self) -> None:
expected_topic_name = "PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Sto..."
expected_message = """
:orange_circle: **[PIETER-UBUNTU query result is > 1.0 for 5 minutes on 'Storage on Host Exceeded Threshold'](https://radar-api.service.newrelic.com/accounts/4420147/issues/13bbcdca-f0b6-470d-b0be-b34583c58869?notifier=WEBHOOK)**
```quote
**Priority**: HIGH
**State**: ACTIVATED
**Updated at**: <time:2024-04-22T07:12:29+00:00>
```
```spoiler :file: Incident details
- **Alert policies**: `Golden Signals`
- **Conditions**: `Storage on Host Exceeded Threshold`
- **Total incidents**: 1
- **Incident created at**: <time:2024-04-22T07:12:29+00:00>
- **Invalid fields 1**: *Value is not a supported data type*
- **Invalid field 2**: *Value is not a supported data type*
- **Is valid**: True
```
""".strip()
self.check_webhook(
"incident_with_invalid_zulip_custom_fields",
expected_topic_name,
expected_message,
content_type="application/json",
)
def test_missing_essential_fields_default_payload(self) -> None:
expected_topic_name = "New Relic incident alerts"
expected_message = """
:danger: A New Relic [incident](https://one.newrelic.com/alerts-ai) updated
**Warning**: Unable to use the default notification format because at least one expected field was missing from the incident payload. See [New Relic integration documentation](/integrations/newrelic).
**Missing fields**: `issueUrl`, `title`, `priority`, `totalIncidents`, `state`, `createdAt`, `updatedAt`, `alertPolicyNames`, `alertConditionNames`
""".strip()
self.check_webhook(
"missing_essential_fields_default_payload",
expected_topic_name,
expected_message,
content_type="application/json",
)