From 0133e21626dc8cd3cd910306910f37c121b1e7be Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Fri, 31 May 2024 11:58:18 +0200 Subject: [PATCH] nixos/tests/podman: add test for rootless quadlet --- nixos/tests/podman/default.nix | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/nixos/tests/podman/default.nix b/nixos/tests/podman/default.nix index 3eea45832f0a..f57523cf5888 100644 --- a/nixos/tests/podman/default.nix +++ b/nixos/tests/podman/default.nix @@ -1,5 +1,22 @@ import ../make-test-python.nix ( - { pkgs, lib, ... }: { + { pkgs, lib, ... }: + let + quadletContainerFile = pkgs.writeText "quadlet.container" '' + [Unit] + Description=A test quadlet container + + [Container] + Image=localhost/scratchimg:latest + Exec=bash -c 'trap exit SIGTERM SIGINT; while true; do sleep 1; done' + ContainerName=quadlet + Volume=/nix/store:/nix/store + Volume=/run/current-system/sw/bin:/bin + + [Install] + WantedBy=default.target + ''; + in + { name = "podman"; meta = { maintainers = lib.teams.podman.members; @@ -174,6 +191,16 @@ import ../make-test-python.nix ( with subtest("A podman non-member can not use the docker cli"): docker.fail(su_cmd("docker version", user="mallory")) + with subtest("A rootless quadlet container service is created"): + dir = "/home/alice/.config/containers/systemd" + rootless.succeed(su_cmd("tar cv --files-from /dev/null | podman import - scratchimg")) + rootless.succeed(su_cmd(f"mkdir -p {dir}")) + rootless.succeed(su_cmd(f"cp -f ${quadletContainerFile} {dir}/quadlet.container")) + rootless.systemctl("daemon-reload", "alice") + rootless.systemctl("start quadlet", "alice") + rootless.wait_until_succeeds(su_cmd("podman ps | grep quadlet"), timeout=20) + rootless.systemctl("stop quadlet", "alice") + # TODO: add docker-compose test '';