feat: report a FreeBSD host as needing a reboot when its installed kernel is not the running one
CI / test (3.10) (push) Successful in 25s
CI / test (3.11) (push) Successful in 22s
CI / test (3.12) (push) Successful in 23s
CI / test (3.10) (pull_request) Successful in 24s
CI / test (3.11) (pull_request) Successful in 22s
CI / test (3.12) (pull_request) Successful in 24s

HOST_STATUS_COMMAND also prints freebsd-version -k and -r where
freebsd-version exists. When the two differ, a kernel update was installed
and is not running yet, so the host needs a reboot. When they match, it does
not.
This commit is contained in:
2026-10-08 12:08:21 +02:00
parent 7ba84acad3
commit e1ce72cc5c
3 changed files with 65 additions and 1 deletions
+45
View File
@@ -198,3 +198,48 @@ class TestHostStatusMixin:
def test_not_every_os_driver_has_it(self):
assert not hasattr(OSDriver, "get_host_status")
class TestFreeBSD:
"""freebsd-version -k names the installed kernel, -r the running one; a
patch that replaced the kernel shows as the two differing until the host
boots it. Recorded on a FreeBSD 15.1 host (NetOrk/netork#799)."""
#: What the command printed there before this section existed.
BEFORE = (
"HSTAT_BEGIN\n[kernel]\n15.1-RELEASE\n[modules]\n[timers]\n"
"apt-daily-upgrade.timer \ndnf-automatic.timer \ndnf-automatic-install.timer \n"
"HSTAT_END\n"
)
@staticmethod
def _report(installed: str, running: str) -> str:
return (
f"HSTAT_BEGIN\n[kernel]\n{running}\n[modules]\n"
f"[freebsd-kernel]\n{installed}\n[freebsd-running]\n{running}\n"
"[timers]\napt-daily-upgrade.timer \nHSTAT_END\n"
)
def test_without_the_section_it_is_unknown(self):
assert parse_host_status(self.BEFORE)["reboot_required"] is None
def test_the_running_kernel_is_the_installed_one(self):
status = parse_host_status(self._report("15.1-RELEASE-p4", "15.1-RELEASE-p4"))
assert status["reboot_required"] is False
assert status["reboot_reason"] is None
def test_a_patched_kernel_waits_for_a_reboot(self):
status = parse_host_status(self._report("15.1-RELEASE-p5", "15.1-RELEASE-p4"))
assert status["reboot_required"] is True
assert status["reboot_reason"] == (
"kernel 15.1-RELEASE-p5 installed, 15.1-RELEASE-p4 running"
)
def test_freebsd_does_not_patch_itself_as_far_as_netork_can_tell(self):
status = parse_host_status(self._report("15.1-RELEASE", "15.1-RELEASE"))
assert status["auto_updates"] is None
def test_the_command_asks_only_where_freebsd_version_exists(self):
assert "command -v freebsd-version" in HOST_STATUS_COMMAND
assert "freebsd-version -k" in HOST_STATUS_COMMAND
assert "freebsd-version -r" in HOST_STATUS_COMMAND