lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

nixosTests.systemd-initrd-networkd: handleTest -> runTest

+76 -76
+1 -1
nixos/tests/all-tests.nix
··· 1364 1364 systemd-initrd-luks-tpm2 = runTest ./systemd-initrd-luks-tpm2.nix; 1365 1365 systemd-initrd-luks-unl0kr = runTest ./systemd-initrd-luks-unl0kr.nix; 1366 1366 systemd-initrd-modprobe = runTest ./systemd-initrd-modprobe.nix; 1367 - systemd-initrd-networkd = handleTest ./systemd-initrd-networkd.nix { }; 1367 + systemd-initrd-networkd = import ./systemd-initrd-networkd.nix { inherit runTest; }; 1368 1368 systemd-initrd-networkd-ssh = runTest ./systemd-initrd-networkd-ssh.nix; 1369 1369 systemd-initrd-networkd-openvpn = handleTestOn [ 1370 1370 "x86_64-linux"
+75 -75
nixos/tests/systemd-initrd-networkd.nix
··· 1 - { 2 - system ? builtins.currentSystem, 3 - config ? { }, 4 - pkgs ? import ../.. { inherit system config; }, 5 - lib ? pkgs.lib, 6 - }: 7 - 8 - with import ../lib/testing-python.nix { inherit system pkgs; }; 1 + { runTest }: 9 2 10 3 let 11 - inherit (lib.maintainers) elvishjerricco; 12 - 13 - common = { 14 - boot.initrd.systemd = { 15 - enable = true; 16 - network.wait-online.timeout = 10; 17 - network.wait-online.anyInterface = true; 18 - targets.network-online.requiredBy = [ "initrd.target" ]; 19 - services.systemd-networkd-wait-online.requiredBy = [ "network-online.target" ]; 20 - initrdBin = [ 21 - pkgs.iproute2 22 - pkgs.iputils 23 - pkgs.gnugrep 24 - ]; 4 + common = 5 + { pkgs, ... }: 6 + { 7 + boot.initrd.systemd = { 8 + enable = true; 9 + network.wait-online.timeout = 10; 10 + network.wait-online.anyInterface = true; 11 + targets.network-online.requiredBy = [ "initrd.target" ]; 12 + services.systemd-networkd-wait-online.requiredBy = [ "network-online.target" ]; 13 + initrdBin = [ 14 + pkgs.iproute2 15 + pkgs.iputils 16 + pkgs.gnugrep 17 + ]; 18 + }; 19 + testing.initrdBackdoor = true; 20 + boot.initrd.network.enable = true; 25 21 }; 26 - testing.initrdBackdoor = true; 27 - boot.initrd.network.enable = true; 28 - }; 29 22 30 23 mkFlushTest = 31 24 flush: script: 32 - makeTest { 33 - name = "systemd-initrd-network-${lib.optionalString (!flush) "no-"}flush"; 34 - meta.maintainers = [ elvishjerricco ]; 25 + runTest ( 26 + { lib, ... }: 27 + { 28 + name = "systemd-initrd-network-${lib.optionalString (!flush) "no-"}flush"; 29 + meta.maintainers = with lib.maintainers; [ elvishjerricco ]; 35 30 36 - nodes.machine = { 37 - imports = [ common ]; 31 + nodes.machine = 32 + { pkgs, ... }: 33 + { 34 + imports = [ common ]; 38 35 39 - boot.initrd.network.flushBeforeStage2 = flush; 40 - systemd.services.check-flush = { 41 - requiredBy = [ "multi-user.target" ]; 42 - before = [ 43 - "network-pre.target" 44 - "multi-user.target" 45 - "shutdown.target" 46 - ]; 47 - conflicts = [ "shutdown.target" ]; 48 - wants = [ "network-pre.target" ]; 49 - unitConfig.DefaultDependencies = false; 50 - serviceConfig.Type = "oneshot"; 51 - path = [ 52 - pkgs.iproute2 53 - pkgs.iputils 54 - pkgs.gnugrep 55 - ]; 56 - inherit script; 57 - }; 58 - }; 36 + boot.initrd.network.flushBeforeStage2 = flush; 37 + systemd.services.check-flush = { 38 + requiredBy = [ "multi-user.target" ]; 39 + before = [ 40 + "network-pre.target" 41 + "multi-user.target" 42 + "shutdown.target" 43 + ]; 44 + conflicts = [ "shutdown.target" ]; 45 + wants = [ "network-pre.target" ]; 46 + unitConfig.DefaultDependencies = false; 47 + serviceConfig.Type = "oneshot"; 48 + path = [ 49 + pkgs.iproute2 50 + pkgs.iputils 51 + pkgs.gnugrep 52 + ]; 53 + inherit script; 54 + }; 55 + }; 56 + 57 + testScript = '' 58 + machine.wait_for_unit("network-online.target") 59 + machine.succeed( 60 + "ip addr | grep 10.0.2.15", 61 + "ping -c1 10.0.2.2", 62 + ) 63 + machine.switch_root() 64 + 65 + machine.wait_for_unit("multi-user.target") 66 + ''; 67 + } 68 + ); 69 + in 70 + { 71 + basic = runTest ( 72 + { lib, ... }: 73 + { 74 + name = "systemd-initrd-network"; 75 + meta.maintainers = with lib.maintainers; [ elvishjerricco ]; 76 + 77 + nodes.machine = common; 59 78 60 79 testScript = '' 61 80 machine.wait_for_unit("network-online.target") ··· 65 84 ) 66 85 machine.switch_root() 67 86 87 + # Make sure the systemd-network user was set correctly in initrd 68 88 machine.wait_for_unit("multi-user.target") 89 + machine.succeed("[ $(stat -c '%U,%G' /run/systemd/netif/links) = systemd-network,systemd-network ]") 90 + machine.succeed("ip addr show >&2") 91 + machine.succeed("ip route show >&2") 69 92 ''; 70 - }; 71 - 72 - in 73 - { 74 - basic = makeTest { 75 - name = "systemd-initrd-network"; 76 - meta.maintainers = [ elvishjerricco ]; 77 - 78 - nodes.machine = common; 79 - 80 - testScript = '' 81 - machine.wait_for_unit("network-online.target") 82 - machine.succeed( 83 - "ip addr | grep 10.0.2.15", 84 - "ping -c1 10.0.2.2", 85 - ) 86 - machine.switch_root() 87 - 88 - # Make sure the systemd-network user was set correctly in initrd 89 - machine.wait_for_unit("multi-user.target") 90 - machine.succeed("[ $(stat -c '%U,%G' /run/systemd/netif/links) = systemd-network,systemd-network ]") 91 - machine.succeed("ip addr show >&2") 92 - machine.succeed("ip route show >&2") 93 - ''; 94 - }; 93 + } 94 + ); 95 95 96 96 doFlush = mkFlushTest true '' 97 97 if ip addr | grep 10.0.2.15; then