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:
parent
28853d8954
commit
65792923af
|
@ -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 {};
|
||||
|
|
19
nixos/tests/nixos-install-simple
Executable file
19
nixos/tests/nixos-install-simple
Executable 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
|
49
nixos/tests/systemd-machinectl.nix
Normal file
49
nixos/tests/systemd-machinectl.nix
Normal 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}");
|
||||
'';
|
||||
})
|
Loading…
Reference in a new issue