From f2957822a3748c91e678657a1cfd009b0440bbfd Mon Sep 17 00:00:00 2001 From: Robbie Buxton Date: Wed, 4 Sep 2024 14:22:56 +0900 Subject: [PATCH] fixed issue by adding lingering to stop rootless user being killed Signed-off-by: Robbie Buxton --- modules/nixos/tests/gvisor.nix | 1 + modules/nixos/tests/k3s-rootless.nix | 1 + modules/nixos/tests/push-n-pull.nix | 1 + modules/nixos/tests/snapshotter.nix | 16 +++------------- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/modules/nixos/tests/gvisor.nix b/modules/nixos/tests/gvisor.nix index c899531..0a2aeca 100644 --- a/modules/nixos/tests/gvisor.nix +++ b/modules/nixos/tests/gvisor.nix @@ -70,6 +70,7 @@ in { users.users.alice = { uid = 1000; isNormalUser = true; + linger = true; }; environment.variables = { diff --git a/modules/nixos/tests/k3s-rootless.nix b/modules/nixos/tests/k3s-rootless.nix index 44c9459..4672b9b 100644 --- a/modules/nixos/tests/k3s-rootless.nix +++ b/modules/nixos/tests/k3s-rootless.nix @@ -26,6 +26,7 @@ users.users.alice = { uid = 1000; isNormalUser = true; + linger = true; }; }; diff --git a/modules/nixos/tests/push-n-pull.nix b/modules/nixos/tests/push-n-pull.nix index 404e154..90980f6 100644 --- a/modules/nixos/tests/push-n-pull.nix +++ b/modules/nixos/tests/push-n-pull.nix @@ -93,6 +93,7 @@ in { users.users.alice = { uid = 1000; isNormalUser = true; + linger = true; }; environment.variables = { diff --git a/modules/nixos/tests/snapshotter.nix b/modules/nixos/tests/snapshotter.nix index 5adcdd8..c098986 100644 --- a/modules/nixos/tests/snapshotter.nix +++ b/modules/nixos/tests/snapshotter.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: let helloDrvFile = pkgs.nix-snapshotter.buildImage { - name = "ghcr.io/pdtpartners/hello-world"; + name = "ghcr.io/nix-snapshotter/hello-world"; tag = "latest"; config.entrypoint = [ (pkgs.writeShellScript "hello-world" '' @@ -88,6 +88,7 @@ in { users.users.alice = { uid = 1000; isNormalUser = true; + linger = true; }; environment.variables = { @@ -120,30 +121,19 @@ in { ]; in '' - def collect_coverage(machine): - coverfiles = machine.succeed("ls /tmp/go-cover").split() - for coverfile in coverfiles: - machine.copy_from_vm(f"/tmp/go-cover/{coverfile}", f"build/go-cover/${config.name}-{machine.name}") - def wait_for_unit(machine, service, user = "alice"): if "rootless" in machine.name: machine.wait_until_succeeds(f"systemctl --user --machine={user}@ is-active {service}") else: machine.wait_for_unit(service) - def stop_unit(machine, service, user = "alice"): - if "rootless" in machine.name: - machine.succeed(f"systemctl --user --machine={user}@ stop {service}") - else: - machine.succeed(f"systemctl stop {service}") - def test(machine, sudo_su = ""): wait_for_unit(machine, "nix-snapshotter.service") wait_for_unit(machine, "containerd.service") wait_for_unit(machine, "preload-containerd.service") with subtest(f"{machine.name}: Run container with an executable outPath"): - out = machine.succeed(f"{sudo_su} nerdctl run --rm ghcr.io/pdtpartners/hello-world") + out = machine.succeed(f"{sudo_su} nerdctl run ghcr.io/nix-snapshotter/hello-world") assert "Hello, world!" in out with subtest(f"{machine.name}: Run container with CNI built with pkgs.dockerTools.buildImage"):