diff options
author | markuskowa <markus.kowalewski@gmail.com> | 2022-08-16 11:44:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 11:44:23 +0200 |
commit | 7511c04c10b4989317124f3c1b6942446be8e55d (patch) | |
tree | ab93e96a295bb5419f30e6908a5d1509a29aaab2 /nixos | |
parent | b81a4af7f0ba21f0905a4059f8cf6a4c5995c1c9 (diff) | |
parent | 8d2fd875b789a34b1e27f335df93a51d9c6cd576 (diff) |
Merge pull request #186310 from ck3d/machinectl-auto-start
nixos/test/systemd-machinectl: Add auto-start test
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/systemd-machinectl.nix | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/nixos/tests/systemd-machinectl.nix b/nixos/tests/systemd-machinectl.nix index d4a23877aa4c7..57ef95c2725fe 100644 --- a/nixos/tests/systemd-machinectl.nix +++ b/nixos/tests/systemd-machinectl.nix @@ -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"); |