Files
microduck/scripts/systemd-test.Dockerfile
Pierre Rouanet 72475f6ad0 Drive a real update against real systemd
The last item of the plan in install-path-gap.md, and the one everything else is
blind to: every other check in the tree drives the engine against a stub
`systemctl`, so none of them can see whether a restart *happened*.

`scripts/systemd-test.sh` boots systemd as pid 1, mints three signed releases
carrying real units and a real `updaterd`, installs one, applies the next through
the running daemon, and then applies one shipping a unit that cannot start. It
observes four things nothing else can:

  - `on_apply` really restarts what the release ships — asserted on the unit's main
    PID changing, not on a command having been issued;
  - the deferred transient timer really fires and really replaces `updaterd`, in
    about four seconds, and the successor runs the new release. A child process
    could not: it would sit in the cgroup being killed. That was the reason for
    `systemd-run` and, until now, an untested claim;
  - `hooks/postinstall` really installs, enables and starts a unit the board has
    never had;
  - a unit that installs cleanly and cannot start fails the update and names itself,
    rather than reverting with "not healthy within 30s: unreachable" — bug 1, and the
    only class the cheaper items cannot reach.

Docker rather than systemd-nspawn, which the plan proposed. The objection to
privileged containers *in CI* stands and this is not CI; what decided it is the
plan's own argument for ranking this last — a check that can only run on a machine
nobody develops on stops being read. Docker Desktop runs systemd as pid 1 on the
laptop this was written on. nspawn does not.

The fixture is its own example rather than a flag on `fake-release`, which
deliberately mints releases with no units because it exists to drive the engine
where systemd is not present.

Two injections are left, both cheap now the harness exists: `systemd-run` failing,
and `enable --now` on a unit whose `User=` does not exist.

Not in CI: it needs --privileged and the host's cgroup filesystem, and the `board`
job is already the slowest thing in the loop. Run it when `on_apply`, the deferred
restarts or the hook change.

Assisted-by: Claude:claude-opus-5
2026-08-11 18:22:23 +02:00

22 lines
1.1 KiB
Docker

# The image `scripts/systemd-test.sh` boots, and the only place in this repository where systemd
# runs as pid 1.
#
# Trixie, unlike `dev-build.Dockerfile`: this one *runs* what a board runs rather than building it,
# so it should be the userland we ship rather than the older one binaries are built against.
#
# `systemd` and `dbus` only. The point is a real init with real cgroups and real transient timers,
# and everything else the update needs — the binaries, the units, the hook — arrives inside the
# signed releases the harness mints, exactly as it does on a board.
FROM debian:trixie-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends systemd dbus \
&& rm -rf /var/lib/apt/lists/*
# systemd's own convention for "stop, cleanly". Without it `docker stop` sends SIGTERM, which pid 1
# systemd reads as a request to re-exec rather than to shut down.
STOPSIGNAL SIGRTMIN+3
# `/lib/systemd/systemd`, because Debian's slim images ship no `/sbin/init` symlink — the harness
# passes it explicitly and this only records why.
CMD ["/lib/systemd/systemd"]