1 import ./make-test-python.nix ({ lib, ... }: {
2 name = "systemd-initrd-bridge";
3 meta.maintainers = [ lib.maintainers.majiir ];
5 # Tests bridge interface configuration in systemd-initrd.
7 # The 'a' and 'b' nodes are connected to a 'bridge' node through different
8 # links. The 'bridge' node configures a bridge across them. It waits forever
9 # in initrd (stage 1) with networking enabled. 'a' and 'b' ping 'bridge' to
10 # test connectivity with the bridge interface. Then, 'a' pings 'b' to test
14 bridge = { config, lib, ... }: {
15 boot.initrd.systemd.enable = true;
16 boot.initrd.network.enable = true;
17 boot.initrd.systemd.services.boot-blocker = {
18 before = [ "initrd.target" ];
19 wantedBy = [ "initrd.target" ];
20 script = "sleep infinity";
21 serviceConfig.Type = "oneshot";
24 networking.primaryIPAddress = "192.168.1.${toString config.virtualisation.test.nodeNumber}";
26 virtualisation.vlans = [ 1 2 ];
27 networking.bridges.br0.interfaces = [ "eth1" "eth2" ];
29 networking.interfaces = {
30 eth1.ipv4.addresses = lib.mkForce [];
31 eth2.ipv4.addresses = lib.mkForce [];
32 br0.ipv4.addresses = [{
33 address = config.networking.primaryIPAddress;
40 virtualisation.vlans = [ 1 ];
43 b = { config, ... }: {
44 virtualisation.vlans = [ 2 ];
45 networking.primaryIPAddress = lib.mkForce "192.168.1.${toString config.virtualisation.test.nodeNumber}";
46 networking.interfaces.eth1.ipv4.addresses = lib.mkForce [{
47 address = config.networking.primaryIPAddress;
55 a.wait_for_unit("network.target")
56 b.wait_for_unit("network.target")
58 a.succeed("ping -n -w 10 -c 1 bridge >&2")
59 b.succeed("ping -n -w 10 -c 1 bridge >&2")
61 a.succeed("ping -n -w 10 -c 1 b >&2")