Merge pull request #186310 from ck3d/machinectl-auto-start
nixos/test/systemd-machinectl: Add auto-start test
This commit is contained in:
commit
7511c04c10
1 changed files with 23 additions and 4 deletions
|
@ -33,12 +33,12 @@ import ./make-test-python.nix (
|
|||
networking.useNetworkd = true;
|
||||
networking.useDHCP = false;
|
||||
|
||||
# open DHCP server on interface to container
|
||||
networking.firewall.trustedInterfaces = [ "ve-+" ];
|
||||
|
||||
# do not try to access cache.nixos.org
|
||||
nix.settings.substituters = lib.mkForce [ ];
|
||||
|
||||
# auto-start container
|
||||
systemd.targets.machines.wants = [ "systemd-nspawn@${containerName}.service" ];
|
||||
|
||||
virtualisation.additionalPaths = [ containerSystem ];
|
||||
};
|
||||
|
||||
|
@ -59,8 +59,19 @@ import ./make-test-python.nix (
|
|||
machine.succeed("machinectl start ${containerName}");
|
||||
machine.wait_until_succeeds("systemctl -M ${containerName} is-active default.target");
|
||||
|
||||
# Test nss_mymachines without nscd
|
||||
machine.succeed('LD_LIBRARY_PATH="/run/current-system/sw/lib" getent -s hosts:mymachines hosts ${containerName}');
|
||||
|
||||
# Test failing nss_mymachines via nscd
|
||||
# nscd has not enough rights to connect to systemd bus
|
||||
# via sd_bus_open_system() in
|
||||
# https://github.com/systemd/systemd/blob/main/src/nss-mymachines/nss-mymachines.c#L287
|
||||
machine.fail("getent hosts ${containerName}");
|
||||
|
||||
# Test systemd-nspawn network configuration
|
||||
machine.succeed("ping -n -c 1 ${containerName}");
|
||||
machine.succeed("systemctl stop nscd");
|
||||
machine.succeed('LD_LIBRARY_PATH="/run/current-system/sw/lib" ping -n -c 1 ${containerName}');
|
||||
machine.succeed("systemctl start nscd");
|
||||
|
||||
# Test systemd-nspawn uses a user namespace
|
||||
machine.succeed("test $(machinectl status ${containerName} | grep 'UID Shift: ' | wc -l) = 1")
|
||||
|
@ -73,6 +84,14 @@ import ./make-test-python.nix (
|
|||
machine.succeed("machinectl reboot ${containerName}");
|
||||
machine.wait_until_succeeds("systemctl -M ${containerName} is-active default.target");
|
||||
|
||||
# Restart machine
|
||||
machine.shutdown()
|
||||
machine.start()
|
||||
machine.wait_for_unit("default.target");
|
||||
|
||||
# Test auto-start
|
||||
machine.succeed("machinectl show ${containerName}")
|
||||
|
||||
# Test machinectl stop
|
||||
machine.succeed("machinectl stop ${containerName}");
|
||||
machine.wait_until_succeeds("test $(systemctl is-active systemd-nspawn@${containerName}) = inactive");
|
||||
|
|
Loading…
Reference in a new issue