diff options
author | Christian Kögler <ck3d@gmx.de> | 2019-08-22 22:45:20 +0200 |
---|---|---|
committer | Franz Pletz <fpletz@fnordicwalking.de> | 2019-09-13 17:33:11 +0200 |
commit | 65792923afe7b48708b59c57c380c0e35cb836af (patch) | |
tree | 65286957dbb8d4b8e809c5a3f85c431c4fbf7bb9 /nixos/tests/systemd-machinectl.nix | |
parent | 28853d8954199bc7944797c260d8116a68da2b46 (diff) |
nixos: added machinectl test
Diffstat (limited to 'nixos/tests/systemd-machinectl.nix')
-rw-r--r-- | nixos/tests/systemd-machinectl.nix | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/nixos/tests/systemd-machinectl.nix b/nixos/tests/systemd-machinectl.nix new file mode 100644 index 0000000000000..f28941bca5ae5 --- /dev/null +++ b/nixos/tests/systemd-machinectl.nix @@ -0,0 +1,49 @@ +import ./make-test.nix (let + + container = { ... }: { + boot.isContainer = true; + + # use networkd to obtain systemd network setup + networking.useNetworkd = true; + + # systemd-nspawn expects /sbin/init + boot.loader.initScript.enable = true; + + imports = [ ../modules/profiles/minimal.nix ]; + }; + + containerSystem = (import ../lib/eval-config.nix { + modules = [ container ]; + }).config.system.build.toplevel; + + containerName = "container"; + +in { + name = "systemd-machinectl"; + + machine = { lib, ... }: { + # use networkd to obtain systemd network setup + networking.useNetworkd = true; + + # open DHCP server on interface to container + networking.firewall.trustedInterfaces = [ "ve-+" ]; + + # do not try to access cache.nixos.org + nix.binaryCaches = lib.mkForce []; + + virtualisation.pathsInNixDB = [ containerSystem ]; + }; + + testScript = '' + startAll; + + $machine->waitForUnit("default.target"); + $machine->succeed("mkdir -p ${containerRoot}"); + $machine->succeed("${./nixos-install-simple} /var/lib/machines/${containerName} ${containerSystem}"); + + $machine->succeed("machinectl start ${containerName}"); + $machine->waitUntilSucceeds("systemctl -M ${containerName} is-active default.target"); + $machine->succeed("ping -n -c 1 ${containerName}"); + $machine->succeed("machinectl stop ${containerName}"); + ''; +}) |