nixos/tests/podman: add test for rootless quadlet

This commit is contained in:
Dawid Dziurla 2024-05-31 11:58:18 +02:00
parent 25ad0cdbfc
commit 0133e21626
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B

View File

@ -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
'';