tests/systemd-user-linger: test clearing lingering users
Split the existing system-user-linger tests into two: one which tests lingering is set up for the correct users and only the correct users, and one which checks that lingering is cleared for users that don't exist. This means that the latter test now also ensures the lingering configuration is handled even if there are no users configured who should be lingering, where previously such lingering configuration wouldn't be touched.
This commit is contained in:
@@ -1510,6 +1510,7 @@ in
|
||||
systemd-sysusers-password-option-override-ordering = runTest ./systemd-sysusers-password-option-override-ordering.nix;
|
||||
systemd-timesyncd-nscd-dnssec = runTest ./systemd-timesyncd-nscd-dnssec.nix;
|
||||
systemd-user-linger = runTest ./systemd-user-linger.nix;
|
||||
systemd-user-linger-purge = runTest ./systemd-user-linger-purge.nix;
|
||||
systemd-user-tmpfiles-rules = runTest ./systemd-user-tmpfiles-rules.nix;
|
||||
systemd-userdbd = runTest ./systemd-userdbd.nix;
|
||||
systemtap = handleTest ./systemtap.nix { };
|
||||
|
||||
29
nixos/tests/systemd-user-linger-purge.nix
Normal file
29
nixos/tests/systemd-user-linger-purge.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
# This test checks #418101, where lingering users would not be cleared up if
|
||||
# the configuration is updated to remove lingering from all users.
|
||||
rec {
|
||||
name = "systemd-user-linger-purge";
|
||||
|
||||
nodes.machine = {
|
||||
users.users = {
|
||||
bob = {
|
||||
isNormalUser = true;
|
||||
linger = false;
|
||||
uid = 1001;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript =
|
||||
let
|
||||
uidStrings = builtins.mapAttrs (k: v: builtins.toString v.uid) nodes.machine.users.users;
|
||||
in
|
||||
''
|
||||
machine.fail("test -e /var/lib/systemd/linger/bob")
|
||||
machine.fail("systemctl status user-${uidStrings.bob}.slice")
|
||||
|
||||
with subtest("missing users have linger purged"):
|
||||
machine.succeed("touch /var/lib/systemd/linger/alice")
|
||||
machine.systemctl("restart linger-users")
|
||||
machine.succeed("test ! -e /var/lib/systemd/linger/alice")
|
||||
'';
|
||||
}
|
||||
@@ -27,10 +27,5 @@ rec {
|
||||
|
||||
machine.fail("test -e /var/lib/systemd/linger/bob")
|
||||
machine.fail("systemctl status user-${uidStrings.bob}.slice")
|
||||
|
||||
with subtest("missing users have linger purged"):
|
||||
machine.succeed("touch /var/lib/systemd/linger/missing")
|
||||
machine.systemctl("restart linger-users")
|
||||
machine.succeed("test ! -e /var/lib/systemd/linger/missing")
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user