about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorDawid Dziurla <dawidd0811@gmail.com>2024-05-31 11:58:18 +0200
committerDawid Dziurla <dawidd0811@gmail.com>2024-05-31 16:02:15 +0200
commit0133e21626dc8cd3cd910306910f37c121b1e7be (patch)
tree5a0b841b48bc342aa33766233a2f8fc0bd028181 /nixos/tests
parent25ad0cdbfcd2e3d0c62a77cf78a2c2067ac7831b (diff)
nixos/tests/podman: add test for rootless quadlet
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/podman/default.nix29
1 files changed, 28 insertions, 1 deletions
diff --git a/nixos/tests/podman/default.nix b/nixos/tests/podman/default.nix
index 3eea45832f0a6..f57523cf58886 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
 
     '';