Drop the hardcoded-domain FQDN regex and every hardcoded domain from commons. Node identity is now explicit in node.env: APEX_NODE_FQDN (real FQDN, traefik Host()), APEX_NODE_HOST (public host name — backup --host, obs/notify instance), APEX_SUBNET. The short name (log prefix, sync/<node> branch, messages) is derived as the first host label. notify instance is just the host (no hardcoded prefix); the git bot identity moves to APEX_GIT_AUTHOR_NAME/EMAIL (node.env) with generic defaults. Alloy node+instance labels use APEX_NODE_HOST. Fallbacks keep a node working if it omits a var (host<-fqdn<-hostname). BREAKING CHANGE: removes APEX_NODE and APEX_CLUSTER env vars; node name is now derived from APEX_NODE_FQDN
25 lines
907 B
Python
25 lines
907 B
Python
# tests/test_notify.py
|
|
import unittest
|
|
from engine.lib.notify import build_text
|
|
|
|
class TestNotify(unittest.TestCase):
|
|
def test_instance_is_the_host(self):
|
|
t = build_text("Title", "msg", "icarus.example.com", "INFO", "2026-07-04 00:00:00 MSK")
|
|
self.assertIn("icarus.example.com", t)
|
|
self.assertIn("#instance_icarus_example_com", t) # dots -> underscores in the hashtag
|
|
|
|
def test_html_escaped_and_truncated(self):
|
|
t = build_text("A & B", "<script>" + "x" * 300, "d", "ERROR", "T")
|
|
self.assertIn("A & B", t)
|
|
self.assertIn("<script>", t)
|
|
self.assertIn("...", t)
|
|
self.assertIn("escalation:</b> critical", t.lower())
|
|
|
|
def test_success_is_resolved(self):
|
|
t = build_text("T", "m", "d", "SUCCESS", "T")
|
|
self.assertIn("Resolved", t)
|
|
self.assertIn("✅", t)
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|