Support Ubuntu 22.04 (agent and server on Python 3.10)
The server only needed Python 3.11 for tomllib. Fall back to a small parser for the flat key = value subset the config uses, checked against tomllib on the shipped example. Relax the installer's version check to 3.10 and list Ubuntu 22.04 as supported for agents and server. Add status tests using uname -v / package versions captured from real 22.04.5 and 24.04.4 HWE hosts, confirming the Ubuntu build mapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
48f2d155af
commit
16d647cf9c
7 files changed
+92
-9
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import os
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
from helpers import tempdir
|
||||
from helpers import REPO, tempdir
|
||||
from kernelwatch import auth, config
|
||||
from kernelwatch.report import ReportError, sanitize
|
||||
|
||||
@@ -66,6 +67,26 @@ class ConfigTest(unittest.TestCase):
|
||||
with self.assertRaises(SystemExit):
|
||||
config.load(self.write(tmp, "secure_cookies = 1\n"))
|
||||
|
||||
def test_fallback_parser_matches_tomllib(self):
|
||||
"""Python 3.10 has no tomllib; the fallback must read the same configs."""
|
||||
if config.tomllib is None:
|
||||
self.skipTest("tomllib not available to compare against")
|
||||
samples = [open(os.path.join(REPO, "server", "server.toml.example")).read(),
|
||||
"db_path = '/srv/kw.db' # literal\nlisten_port = 8_080\n"
|
||||
"stale_after_hours = 2.5\nsecure_cookies = false\nlisten_host = \"0.0.0.0\"\n"]
|
||||
for text in samples:
|
||||
with self.subTest(text=text[:40]):
|
||||
self.assertEqual(config._parse_flat_toml(text, "x"), config.tomllib.loads(text))
|
||||
|
||||
def test_load_without_tomllib(self):
|
||||
with tempdir() as tmp, mock.patch.object(config, "tomllib", None):
|
||||
cfg = config.load(self.write(tmp, 'listen_port = 9000 # comment\ndb_path = "/x/kw.db"\n'))
|
||||
self.assertEqual((cfg.listen_port, cfg.db_path), (9000, "/x/kw.db"))
|
||||
for bad in ("[server]\n", "listen_port = [1]\n", 'db_path = "a\\b"\n',
|
||||
"listen_port = 1\nlisten_port = 2\n", 'db_path = "unterminated\n'):
|
||||
with self.subTest(bad=bad), self.assertRaises(SystemExit):
|
||||
config.load(self.write(tmp, bad))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -87,6 +87,19 @@ class EvaluateTest(unittest.TestCase):
|
||||
rep["kernel_running_pkg_version"] = "6.14.0-33.34~24.04.1"
|
||||
self.assertEqual(self.level(rep).level, "reboot")
|
||||
|
||||
def test_real_ubuntu_hwe_builds(self):
|
||||
# Captured from real hosts (22.04.5 and 24.04.4, both HWE).
|
||||
for running, build, pkg in (
|
||||
("6.8.0-138-generic", "#138~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 7 13:43:15 UTC",
|
||||
"6.8.0-138.138~22.04.1"),
|
||||
("7.0.0-38-generic", "#38~24.04.4-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 14 16:37:11 UTC 2",
|
||||
"7.0.0-38.38~24.04.4"),
|
||||
):
|
||||
with self.subTest(build=build):
|
||||
rep = report(kernel_running=running, kernel_newest_installed=running, needrestart_ksta=None,
|
||||
kernel_build=build, kernel_running_pkg_version=pkg)
|
||||
self.assertEqual(self.level(rep).level, "ok", self.level(rep).reasons)
|
||||
|
||||
def test_unrecognised_build_falls_back(self):
|
||||
rep = report(needrestart_ksta=None, kernel_build="#1 SMP custom",
|
||||
kernel_running_pkg_version="1.0", kernel_newest_installed="6.12.60+deb13-amd64")
|
||||
|
||||
Reference in new issue
Block a user