mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-29 10:06:41 +00:00
OCI manager Apps - App tab: containers installed from an OCI image are identified from their installation record; the application and image versions are shown and an update is detected by image digest; repository link; Refresh data. - Updates tab for OCI containers: Update and Recreate run the same flow as the OCI menu in the Monitor terminal; the pre-update backup can be kept in a backup storage; scheduled image updates with an optional minimum age. - Logs tab: console output of the application, kept on the host (lxc.console.logfile + logrotate) and followed live. - The Proxmox console opens a shell (cmode: shell) when the image has one. - A damaged image download is fetched again before failing. - Multi-container applications open at their LAN address; volume mount points on block storage report their usage. Monitor - Proxmox notifications are delivered to a loopback-only HTTP listener when HTTPS is enabled, so they no longer fail certificate verification. - Log persistence counts recurring patterns only; an ended burst is not reported as persistent and its warning clears on its own (#386). - Proxmox notification config backups are deduplicated and capped at three. - The update icon on the Apps page opens the container on its Updates tab. - Version 1.2.6.2-beta and its release notes in every Monitor language. Docs - OCI manager Apps and Audit & Report rebuilt as per-page message files, with a new page for OCI containers in the Monitor. - Seven pages fixed where rich-text tags were missing from t.rich. Translations - Spanish fixes across the OCI engine, the Monitor and the TUI menus. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
115 lines
4.3 KiB
Python
115 lines
4.3 KiB
Python
import json
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from queue import Queue
|
|
from unittest import mock
|
|
|
|
|
|
SCRIPTS_DIR = Path(__file__).resolve().parents[1]
|
|
if str(SCRIPTS_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SCRIPTS_DIR))
|
|
|
|
import notification_events # noqa: E402
|
|
import notification_templates # noqa: E402
|
|
import post_install_versions # noqa: E402
|
|
|
|
|
|
class NotificationUpdatePolicyTests(unittest.TestCase):
|
|
def test_apt_listchanges_system_mail_has_its_own_update_event(self):
|
|
watcher = notification_events.ProxmoxHookWatcher(Queue())
|
|
classified = watcher._classify_pve(
|
|
"system-mail",
|
|
"info",
|
|
"Novedades de apt-listchanges para amd",
|
|
"zfs-linux recommends that all users update absolute paths",
|
|
)
|
|
self.assertEqual(classified, ("apt_listchanges", "node", ""))
|
|
|
|
def test_regular_system_mail_remains_available(self):
|
|
watcher = notification_events.ProxmoxHookWatcher(Queue())
|
|
with mock.patch.object(notification_events, "_record_smartd_observation_impl"):
|
|
classified = watcher._classify_pve(
|
|
"system-mail",
|
|
"warning",
|
|
"SMART error (CurrentPendingSector) detected on host",
|
|
"Device: /dev/sda",
|
|
)
|
|
self.assertEqual(classified, ("system_mail", "node", ""))
|
|
|
|
def test_apt_listchanges_body_is_preserved_and_attributed(self):
|
|
watcher = notification_events.ProxmoxHookWatcher(Queue())
|
|
upstream = (
|
|
"zfs-linux (2.2.4-2) unstable; urgency=medium\n\n"
|
|
" Package-maintainer recommendation.\n\n"
|
|
" -- Maintainer <maintainer@example.com>"
|
|
)
|
|
result = watcher.process_webhook({
|
|
"title": "apt-listchanges: News for host",
|
|
"message": upstream,
|
|
"severity": "info",
|
|
"fields": {"type": "system-mail", "hostname": "pve-test"},
|
|
})
|
|
self.assertTrue(result["accepted"])
|
|
event = watcher._queue.get_nowait()
|
|
self.assertEqual(event.event_type, "apt_listchanges")
|
|
self.assertEqual(event.data["reason"], upstream)
|
|
|
|
rendered = notification_templates.render_template(
|
|
event.event_type,
|
|
event.data,
|
|
)
|
|
self.assertIn("not a ProxMenux recommendation", rendered["body_text"])
|
|
self.assertIn(upstream, rendered["body_text"])
|
|
|
|
def test_smaller_pending_subset_does_not_notify_again(self):
|
|
updates = [
|
|
{"key": "persistent_network", "available_version": "1.2"},
|
|
]
|
|
notified = {
|
|
"log2ram": {"1.4"},
|
|
"persistent_network": {"1.2"},
|
|
}
|
|
self.assertEqual(
|
|
notification_events._new_post_install_update_versions(updates, notified),
|
|
{},
|
|
)
|
|
|
|
def test_new_version_of_existing_tool_is_detected(self):
|
|
updates = [
|
|
{"key": "persistent_network", "available_version": "1.3"},
|
|
]
|
|
notified = {"persistent_network": {"1.2"}}
|
|
self.assertEqual(
|
|
notification_events._new_post_install_update_versions(updates, notified),
|
|
{"persistent_network": "1.3"},
|
|
)
|
|
|
|
def test_notified_versions_share_the_existing_snapshot_file(self):
|
|
with tempfile.TemporaryDirectory() as temporary:
|
|
snapshot_path = Path(temporary) / "updates_available.json"
|
|
cache = {
|
|
"scanned_at": 123.0,
|
|
"updates": [
|
|
{"key": "log2ram", "available_version": "1.4"},
|
|
],
|
|
}
|
|
with mock.patch.object(post_install_versions, "_UPDATES_JSON", snapshot_path), \
|
|
mock.patch.object(post_install_versions, "_cache", cache):
|
|
post_install_versions.save_notified_versions(
|
|
{"log2ram": {"1.3", "1.4"}}
|
|
)
|
|
self.assertEqual(
|
|
post_install_versions.load_notified_versions(),
|
|
{"log2ram": {"1.3", "1.4"}},
|
|
)
|
|
payload = json.loads(snapshot_path.read_text(encoding="utf-8"))
|
|
self.assertEqual(payload["scanned_at"], 123.0)
|
|
self.assertEqual(payload["updates"], cache["updates"])
|
|
self.assertEqual(payload["notified_versions"]["log2ram"], ["1.3", "1.4"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|