nixosTests.systemd-initrd-networkd: handleTest -> runTest
This commit is contained in:
parent
2fcd5fedf9
commit
dde4a38d69
@ -1364,7 +1364,7 @@ in
|
||||
systemd-initrd-luks-tpm2 = runTest ./systemd-initrd-luks-tpm2.nix;
|
||||
systemd-initrd-luks-unl0kr = runTest ./systemd-initrd-luks-unl0kr.nix;
|
||||
systemd-initrd-modprobe = runTest ./systemd-initrd-modprobe.nix;
|
||||
systemd-initrd-networkd = handleTest ./systemd-initrd-networkd.nix { };
|
||||
systemd-initrd-networkd = import ./systemd-initrd-networkd.nix { inherit runTest; };
|
||||
systemd-initrd-networkd-ssh = runTest ./systemd-initrd-networkd-ssh.nix;
|
||||
systemd-initrd-networkd-openvpn = handleTestOn [
|
||||
"x86_64-linux"
|
||||
|
@ -1,61 +1,80 @@
|
||||
{
|
||||
system ? builtins.currentSystem,
|
||||
config ? { },
|
||||
pkgs ? import ../.. { inherit system config; },
|
||||
lib ? pkgs.lib,
|
||||
}:
|
||||
|
||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||
{ runTest }:
|
||||
|
||||
let
|
||||
inherit (lib.maintainers) elvishjerricco;
|
||||
|
||||
common = {
|
||||
boot.initrd.systemd = {
|
||||
enable = true;
|
||||
network.wait-online.timeout = 10;
|
||||
network.wait-online.anyInterface = true;
|
||||
targets.network-online.requiredBy = [ "initrd.target" ];
|
||||
services.systemd-networkd-wait-online.requiredBy = [ "network-online.target" ];
|
||||
initrdBin = [
|
||||
pkgs.iproute2
|
||||
pkgs.iputils
|
||||
pkgs.gnugrep
|
||||
];
|
||||
common =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
boot.initrd.systemd = {
|
||||
enable = true;
|
||||
network.wait-online.timeout = 10;
|
||||
network.wait-online.anyInterface = true;
|
||||
targets.network-online.requiredBy = [ "initrd.target" ];
|
||||
services.systemd-networkd-wait-online.requiredBy = [ "network-online.target" ];
|
||||
initrdBin = [
|
||||
pkgs.iproute2
|
||||
pkgs.iputils
|
||||
pkgs.gnugrep
|
||||
];
|
||||
};
|
||||
testing.initrdBackdoor = true;
|
||||
boot.initrd.network.enable = true;
|
||||
};
|
||||
testing.initrdBackdoor = true;
|
||||
boot.initrd.network.enable = true;
|
||||
};
|
||||
|
||||
mkFlushTest =
|
||||
flush: script:
|
||||
makeTest {
|
||||
name = "systemd-initrd-network-${lib.optionalString (!flush) "no-"}flush";
|
||||
meta.maintainers = [ elvishjerricco ];
|
||||
runTest (
|
||||
{ lib, ... }:
|
||||
{
|
||||
name = "systemd-initrd-network-${lib.optionalString (!flush) "no-"}flush";
|
||||
meta.maintainers = with lib.maintainers; [ elvishjerricco ];
|
||||
|
||||
nodes.machine = {
|
||||
imports = [ common ];
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [ common ];
|
||||
|
||||
boot.initrd.network.flushBeforeStage2 = flush;
|
||||
systemd.services.check-flush = {
|
||||
requiredBy = [ "multi-user.target" ];
|
||||
before = [
|
||||
"network-pre.target"
|
||||
"multi-user.target"
|
||||
"shutdown.target"
|
||||
];
|
||||
conflicts = [ "shutdown.target" ];
|
||||
wants = [ "network-pre.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig.Type = "oneshot";
|
||||
path = [
|
||||
pkgs.iproute2
|
||||
pkgs.iputils
|
||||
pkgs.gnugrep
|
||||
];
|
||||
inherit script;
|
||||
};
|
||||
};
|
||||
boot.initrd.network.flushBeforeStage2 = flush;
|
||||
systemd.services.check-flush = {
|
||||
requiredBy = [ "multi-user.target" ];
|
||||
before = [
|
||||
"network-pre.target"
|
||||
"multi-user.target"
|
||||
"shutdown.target"
|
||||
];
|
||||
conflicts = [ "shutdown.target" ];
|
||||
wants = [ "network-pre.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
serviceConfig.Type = "oneshot";
|
||||
path = [
|
||||
pkgs.iproute2
|
||||
pkgs.iputils
|
||||
pkgs.gnugrep
|
||||
];
|
||||
inherit script;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("network-online.target")
|
||||
machine.succeed(
|
||||
"ip addr | grep 10.0.2.15",
|
||||
"ping -c1 10.0.2.2",
|
||||
)
|
||||
machine.switch_root()
|
||||
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
'';
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
basic = runTest (
|
||||
{ lib, ... }:
|
||||
{
|
||||
name = "systemd-initrd-network";
|
||||
meta.maintainers = with lib.maintainers; [ elvishjerricco ];
|
||||
|
||||
nodes.machine = common;
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("network-online.target")
|
||||
@ -65,33 +84,14 @@ let
|
||||
)
|
||||
machine.switch_root()
|
||||
|
||||
# Make sure the systemd-network user was set correctly in initrd
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
machine.succeed("[ $(stat -c '%U,%G' /run/systemd/netif/links) = systemd-network,systemd-network ]")
|
||||
machine.succeed("ip addr show >&2")
|
||||
machine.succeed("ip route show >&2")
|
||||
'';
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
basic = makeTest {
|
||||
name = "systemd-initrd-network";
|
||||
meta.maintainers = [ elvishjerricco ];
|
||||
|
||||
nodes.machine = common;
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("network-online.target")
|
||||
machine.succeed(
|
||||
"ip addr | grep 10.0.2.15",
|
||||
"ping -c1 10.0.2.2",
|
||||
)
|
||||
machine.switch_root()
|
||||
|
||||
# Make sure the systemd-network user was set correctly in initrd
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
machine.succeed("[ $(stat -c '%U,%G' /run/systemd/netif/links) = systemd-network,systemd-network ]")
|
||||
machine.succeed("ip addr show >&2")
|
||||
machine.succeed("ip route show >&2")
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
doFlush = mkFlushTest true ''
|
||||
if ip addr | grep 10.0.2.15; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user