summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-03 11:26:12 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-03 11:26:12 +0200
commit7d995ea52d8321495630dd95851626b9664ce133 (patch)
tree7f412fdb1d498b566f0eafbfe2b851647e3b985d /packages
parentba523e6ba3cb02f9b9612b74596d09c45e22dbdb (diff)
downloadmeshbay-7d995ea52d8321495630dd95851626b9664ce133.tar.gz
test(node): check where the systemd units are staged, not what the spec says
test_each_unit_is_installed_where_it_can_run read meshbay-node.spec's %install for `install -D` lines and their destination on the following line. The packaging overhaul (2026-08-31) replaced that section with `cp -a %{_staging_root}/* %{buildroot}/`: the spec no longer places individual files, build-node.sh does, and the spec only declares them in %files. So the test failed against packaging that was correct all along — it was checking a mechanism that no longer existed while the property it defends still held. Both units do land where they can run: build-node.sh:71-76 copies meshbay-node.service to /usr/lib/systemd/system/meshbay-node@.service and meshbay-node-user.service to /usr/lib/systemd/user/meshbay-node.service. It now reads that script. Same guarantee, aimed at the thing that does the work: the template — the one carrying User=%i — into the system directory, and the user unit, which cannot carry User=, into the user one. Checked against three reintroductions of the original defect: swapped destinations, the user unit dropped from staging, and the template renamed. Not verified here: %{_unitdir} and %{_userunitdir} really expanding to those paths. There is no rpm on this machine, so that comes from the RPM convention rather than from `rpm --eval`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AbwJDbNTkiRUh7HTWEoyss
Diffstat (limited to 'packages')
-rw-r--r--packages/meshbay-node/tests/test_packaging_units.py48
1 files changed, 38 insertions, 10 deletions
diff --git a/packages/meshbay-node/tests/test_packaging_units.py b/packages/meshbay-node/tests/test_packaging_units.py
index bbfb536..2b9ad73 100644
--- a/packages/meshbay-node/tests/test_packaging_units.py
+++ b/packages/meshbay-node/tests/test_packaging_units.py
@@ -17,6 +17,9 @@ import pytest
ROOT = Path(__file__).resolve().parents[3]
SYSTEMD = ROOT / "packaging" / "systemd"
SPEC = ROOT / "packaging" / "rpm" / "meshbay-node.spec"
+# Where the files are actually placed: the spec's %install is a blind copy of
+# this script's output (see test_each_unit_is_installed_where_it_can_run).
+BUILD_NODE = ROOT / "packaging" / "build" / "build-node.sh"
pytestmark = pytest.mark.skipif(not SPEC.exists(), reason="packaging not present")
@@ -59,20 +62,45 @@ def test_the_user_unit_names_no_user():
def test_each_unit_is_installed_where_it_can_run():
- spec = SPEC.read_text(encoding="utf-8")
- install = spec.split("%files")[0]
+ """
+ Read where the units are *staged*, not what the spec says.
+
+ This used to inspect `meshbay-node.spec`'s `%install` for `install -D` lines
+ and their destination on the following line. The packaging overhaul
+ (2026-08-31) replaced that section with `cp -a %{_staging_root}/*
+ %{buildroot}/`: the spec no longer places individual files, `build-node.sh`
+ does, and the spec only declares them in `%files`. The test kept reading the
+ spec and failed for months against packaging that was correct all along —
+ checking a mechanism that no longer existed while the property it defends
+ still held.
+
+ So it now reads the script that actually places them. Same guarantee, aimed
+ at the thing that does the work: the template — the one carrying `User=%i` —
+ into the system directory, and the user unit, which cannot carry `User=`,
+ into the user one. systemd refuses the file outright if these are swapped,
+ which is how the original defect presented.
+ """
+ stage = BUILD_NODE.read_text(encoding="utf-8")
# The template goes to the system directory, instantiated per person.
- assert "%{_unitdir}/meshbay-node@.service" in install
+ assert "usr/lib/systemd/system/meshbay-node@.service" in stage, (
+ "the system template is not staged into the system unit directory")
# The user unit goes to the user directory, enabled without a password.
- assert "%{_userunitdir}/meshbay-node.service" in install
+ assert "usr/lib/systemd/user/meshbay-node.service" in stage, (
+ "the per-user unit is not staged into the user unit directory")
- system_line = next(l for l in install.splitlines()
- if "meshbay-node-user.service" in l)
- idx = install.splitlines().index(system_line)
- destination = install.splitlines()[idx + 1]
- assert "_userunitdir" in destination, (
- "the per-user unit is installed as a system unit")
+ # And each comes from the right source file — the two are one `cp` apart,
+ # so a swap would put `User=%i` where systemd will not load it.
+ for source, destination in (
+ ("packaging/systemd/meshbay-node.service",
+ "usr/lib/systemd/system/meshbay-node@.service"),
+ ("packaging/systemd/meshbay-node-user.service",
+ "usr/lib/systemd/user/meshbay-node.service"),
+ ):
+ i = stage.index(source)
+ assert destination in stage[i:i + 200], (
+ f"{source} is not staged to {destination} — check the cp pair in "
+ "build-node.sh")
def test_both_units_are_listed_in_files():