Repository navigation
Conversation
…rt the drop-in last
…nstalls the newest one
make linux builds flock-<version>-linux-{x64,arm64}.tar.gz with their .sha256; build.yml keeps
them as artifacts and betas and releases require them. install.sh picks the newest release (the
newest beta until there is a stable one), checks the archive and runs flock install.
util-linux owns /usr/bin/flock, so the package installs /usr/lib/flock-php/flock with a /usr/bin/flock-php link; flock-php install sets Flock up for the user.
The archives hold flock-php, install.sh runs it, and the AUR package installs /usr/bin/flock-php directly. The comments name the right folder, ~/.config/Flock/bin.
tools/linux-e2e/run.sh installs Flock with install.sh, from archives built from the tree, in a rootless Podman container per distribution that boots systemd (systemd-resolved with global DNS servers, a user session, NetworkManager on Ubuntu and Fedora). It checks the setup (flock-php, flock-dns.service and flock0, the NetworkManager drop-in, setcap, the CA in the system and NSS, HTTPS), NetworkManager taking networking down and a drop-in read after Flock's, drift reported while lookups still work, a resolved restart and a reboot, and that uninstall --purge leaves nothing. --from <ref> installs that ref first and upgrades from it. linux-e2e.yml runs it per distribution when the Linux setup changes, and by hand.
sineld
left a comment
There was a problem hiding this comment.
Thanks, @Nejcc. This is the test #12 needed. The scenarios match the failures we actually hit, and having the conf.d ordering and the latent drift as regression checks is great. A few things I noticed in bba647a/de949b6, none of them blocking:
run.sh:151:install.sh's exit status is lost in the pipe togrep | sed. A failed install only shows up through the checks after it, soset -o pipefailor acheck "install"would make that failure direct.archlinux:latestandfedora:latest: CI can start failing without a change here. That's probably the point of an e2e test, just worth knowing when a run goes red.- CI: the workflow hasn't run yet, since it needs a maintainer's approval on a fork PR. So rootless Podman with
--systemd=alwaysonubuntu-24.04is still unproven there.
|
|
||
| if [ -n "$from" ]; then | ||
| echo "== install $from" | ||
| user 'FLOCK_VERSION=0.0.0-from sh /test/install.sh </dev/null >/tmp/from.log 2>&1' || { cat "$work/from.log" 2>/dev/null; } |
There was a problem hiding this comment.
The log goes to /tmp/from.log inside the container, but the fallback reads $work/from.log on the host. That file never exists, and /test is mounted read-only anyway. So when the --from install fails, nothing is printed and nothing is counted. The run then carries on as a fresh install, while the summary still reads as an upgrade.
Maybe:
check "install $from" user 'FLOCK_VERSION=0.0.0-from sh /test/install.sh </dev/null >/tmp/from.log 2>&1 || { cat /tmp/from.log; exit 1; }'There was a problem hiding this comment.
You're right, that fallback could never fire. In ebfdb53 both installs are now checks that print the tail of the log from inside the container. So a failed --from install counts as a failure and doesn't quietly turn the run into a fresh install. I re-ran Arch with --from 89d0784, and PASS install 89d0784 now shows in the summary.
|
|
||
| build() { # build <version> <source dir> | ||
| make -s -C "$2" -f "$repo/Makefile" linux VERSION="$1" >/dev/null && | ||
| mv "$2"/dist/flock-"$1"-linux-x64.tar.gz* "$work/dist/" |
There was a problem hiding this comment.
make linux builds both linux-x64 and linux-arm64, but only the x64 archive is moved. On an arm64 host, install.sh asks for flock-<v>-linux-arm64.tar.gz, and the curl stand-in's cp fails. That covers GitHub's ubuntu-24.04-arm runners and the Ampere/Graviton boxes I run Flock on. flock-"$1"-linux-*.tar.gz* would cover both.
There was a problem hiding this comment.
Good point about the Ampere/Graviton boxes and the arm runners. Fixed in ebfdb53 with flock-"$1"-linux-*.tar.gz*, so both archives go to the curl stand-in.
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: |
There was a problem hiding this comment.
The drift report this test guards lives in internal/daemon/wildcard.go: checkWildcard calls dns.LinkProblem on Linux. internal/daemon/** isn't in the list, so a change there that broke the report wouldn't run the test. go.mod/go.sum (and maybe cmd/flock/**) may be worth adding too.
There was a problem hiding this comment.
Added internal/daemon/**, cmd/flock/**, go.mod and go.sum in ebfdb53. I'd missed that checkWildcard → dns.LinkProblem path.
| # status_says yes|no <seconds>: waits for `flock-php status` to (not) report flock0. | ||
| status_says() { | ||
| for _ in $(seq "$2"); do | ||
| if user '$F status' 2>/dev/null | grep -q flock0; then [ "$1" = yes ] && return 0; else [ "$1" = no ] && return 0; fi |
There was a problem hiding this comment.
When $F status fails (the daemon isn't running), the output is empty, grep -q flock0 fails, and status_says no returns success. So "status clean" and "status clean again" also pass with a dead daemon. Requiring $F status to succeed in that branch would close it, e.g. out=$(user '$F status' 2>/dev/null) || { sleep 1; continue; }.
There was a problem hiding this comment.
Nice catch, a dead daemon passed as clean. In ebfdb53, status_says only counts a flock-php status that succeeds, and a failing one just waits for the next second, close to your suggestion. So both "status clean" checks now need a running daemon.
- Both installs are checks now: the --from log was read from the host, where it never exists, and the tree's exit status was lost in a pipe. - status_says needs a successful flock-php status, so a dead daemon no longer passes as "status clean". - Move the arm64 archives too, for arm64 hosts and runners. - Run the workflow on internal/daemon (the drift report), cmd/flock, go.mod and go.sum.
|
Thanks for the review, @sineld. The inline points are fixed in ebfdb53. On the top-level ones:
|
|
Since this is dependent on the closed #16 PR, I'm closing this too. Thanks a lot for the PR and sorry for closing, in the future PRs need an issue first so we can discuss whether it makes sense to work on it, before someone actually puts their time and effort into the PR. |
|
No worries, thanks! 👍 |
Refs #12.
Summary
This adds an end-to-end test of Flock on Linux: the one #12 promised, and the source of the results reported there. It installs Flock the way a user would, on real systemd-based Arch, Ubuntu and Fedora systems, checks every part of the setup, breaks it on purpose, and uninstalls it again. It also runs in CI whenever the Linux setup code changes.
Why
Flock's Linux setup changes things a unit test can't reach, and each of them depends on how the distribution is set up:
flock0)Two setups in particular have already broken it, and only a real boot shows it:
flock0.How it works
tools/linux-e2e/run.sh [--from <ref>] [arch] [ubuntu] [fedora]first builds the release archives from the working tree (make linux). Then, for each distribution, it boots a rootless Podman container running systemd, set up like a typical desktop:DNS=9.9.9.9 1.1.1.1)uplink.confdrop-in that usesunmanaged-devices=Flock is installed with the real
install.sh, through acurlstand-in that serves the release downloads from the local archives. With--from <ref>, that ref is installed first, so the run also covers the upgrade.What it checks
flock-phpis installed; util-linux'sflockstill comes first in a new shell.flock-dns.service, theflock0link andzz-flock.confare in place, with no drop-in in resolved's global scope.setcaplets Flock bind ports 80 and 443.*.testresolves throughresolvectlandgetent, including after a lookup outside the TLD.flock0stays unmanaged.networking off/onfollowed by a resolved restart.managed yesis refused.zzz-admin.confread after Flock's is reported byflock-php status.ip address flush dev flock0is reported within 70 s, including while*.teststill resolves.systemctl restart flock-dns.serviceclears it.uninstall --purgeremoves the unit, the link, the drop-in, the CA, the PATH line and the data.CI
.github/workflows/linux-e2e.ymlruns one job per distribution onubuntu-24.04, withfail-fastoff and a 30-minute timeout.internal/cli,internal/dns,internal/certs,internal/ports,install.sh, theMakefile, the harness or the workflow itself. It can also be started by hand (workflow_dispatch).dummymodule itself (sudo modprobe dummy numdummies=0), because a rootless container can't.Results
On
9d631ee, upgraded from18d4050:On Ubuntu and Fedora, the drift is reported while
*.teststill resolves. That's the hidden case this test was written for. On Arch, lookups fail as soon as the address is gone, and the drift is reported as well.Running it locally
You need Podman. A full run takes about 15 minutes, mostly the one-minute status checks and the reboot.