1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 13:41:26 +00:00

nixos: added machinectl test

This commit is contained in:
Christian Kögler 2019-08-22 22:45:20 +02:00 committed by Franz Pletz
parent 28853d8954
commit 65792923af
No known key found for this signature in database
GPG key ID: 846FDED7792617B4
3 changed files with 69 additions and 0 deletions

View file

@ -260,6 +260,7 @@ in
syncthing-relay = handleTest ./syncthing-relay.nix {};
systemd = handleTest ./systemd.nix {};
systemd-confinement = handleTest ./systemd-confinement.nix {};
systemd-machinectl = handleTest ./systemd-machinectl.nix {};
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
systemd-networkd-wireguard = handleTest ./systemd-networkd-wireguard.nix {};
pdns-recursor = handleTest ./pdns-recursor.nix {};

View file

@ -0,0 +1,19 @@
#!/bin/sh -eux
mkdir -p "$1"
ROOT="$(readlink -f $1)"
SYSTEM="$(readlink -f ${2:-./result})"
# create root folders
mkdir -p "$ROOT/etc" "$ROOT/boot"
# install NixOS
nix-env --store "$ROOT" \
--extra-substituters "auto?trusted=1" \
-p "$ROOT/nix/var/nix/profiles/system" --set "$SYSTEM"
# activate NixOS
touch "$ROOT/etc/NIXOS"
nixos-enter --root "$ROOT" \
-- /run/current-system/bin/switch-to-configuration boot

View file

@ -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}");
'';
})