This project has two test levels.
The default integration suite must stay safe for public GitHub runners. It runs
the daemon as an unprivileged host process with -dry-run, uses the Docker
socket provided by the runner, and verifies the event, inspect, policy, cgroup
path resolution, and device discovery pipeline without attaching BPF programs.
Run the CI-safe suite from the repository root:
make go-build
go test -tags=integration -timeout=60s -v ./test/integration/...The native Linux host can also be used for opt-in privileged checks. Do not add these checks to the default GitHub workflow unless they are explicitly guarded, because they require host namespaces, privileged containers, and sometimes systemd DBus access.
The default integration tests cover:
- Docker event subscription for
startevents. - Startup enumeration against currently running containers.
- Container inspection and
/proc/<pid>cgroup parsing. - Host cgroup path resolution for private Docker cgroup namespaces.
/dev/...bind mount detection.- Dry-run device rule generation for
/dev/null. -policy-mode=opt-infiltering: containers withoutswarm-device-access.enable=trueare skipped.- Per-container
swarm-device-access.enablelabel opt-in.
Use this checklist manually on a trusted Linux host when changing cgroup, BPF, or deployment behavior:
-
Build and run the daemon container with host privileges:
make docker-build make docker-run DOCKER_RUN_ARGS="-log-level debug" -
Verify the container has the required runtime wiring:
docker inspect swarm-device-access
-
Start a consumer container with
--label swarm-device-access.enable=trueand a real/dev/...bind mount and confirm the daemon logsdevice mount detectedandadding device rule. (For Swarm stacks, the equivalent placement isdeploy.labels:in the service spec —docker service create --labelwrites to the same location.) -
If the host uses cgroup v2, confirm a
BPF_CGROUP_DEVICEprogram is attached to the consumer cgroup withbpftool. -
Test directory walking with a directory such as
/dev/bus/usbwhen such devices are present. -
Test
-device-allowand-device-denywith a dry-run daemon first, then with the privileged daemon. -
If
/run/dbus/system_bus_socketis mounted and systemd is available, runsystemctl daemon-reloadand verify the daemon logs that it re-applied rules. -
Verify observability by starting with
-metrics-addr :9090and-debug-addr :6060, then checking/healthz,/readyz,/metrics, and/debug/pprof/.