nixos/tests/machinectl: Make network routable

This commit is contained in:
Christian Kögler 2024-03-12 23:03:10 +01:00
parent 1536926ef5
commit de52b2b49e

View file

@ -52,6 +52,11 @@ import ./make-test-python.nix ({ pkgs, ... }:
];
overrideStrategy = "asDropin";
};
# open DHCP for container
networking.firewall.extraCommands = ''
${pkgs.iptables}/bin/iptables -A nixos-fw -i ve-+ -p udp -m udp --dport 67 -j nixos-fw-accept
'';
};
testScript = ''
@ -77,6 +82,12 @@ import ./make-test-python.nix ({ pkgs, ... }:
# Test nss_mymachines via nscd
machine.succeed("getent hosts ${containerName}");
# Test systemd-nspawn network configuration to container
machine.succeed("networkctl --json=short status ve-${containerName} | ${pkgs.jq}/bin/jq -e '.OperationalState == \"routable\"'");
# Test systemd-nspawn network configuration to host
machine.succeed("machinectl shell ${containerName} /run/current-system/sw/bin/networkctl --json=short status host0 | ${pkgs.jq}/bin/jq -r '.OperationalState == \"routable\"'");
# Test systemd-nspawn network configuration
machine.succeed("ping -n -c 1 ${containerName}");