blob: 7548787bc18cb6a555c59f9b14e275b7ea5d3186 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
{ lib, ... }:
{
name = "systemd-initrd-bridge";
meta.maintainers = [ lib.maintainers.majiir ];
# Tests bridge interface configuration in systemd-initrd.
#
# The 'a' and 'b' nodes are connected to a 'bridge' node through different
# links. The 'bridge' node configures a bridge across them. It waits forever
# in initrd (stage 1) with networking enabled. 'a' and 'b' ping 'bridge' to
# test connectivity with the bridge interface. Then, 'a' pings 'b' to test
# the bridge itself.
nodes = {
bridge =
{ config, lib, ... }:
{
boot.initrd.systemd.enable = true;
boot.initrd.network.enable = true;
boot.initrd.systemd.services.boot-blocker = {
before = [ "initrd.target" ];
wantedBy = [ "initrd.target" ];
script = "sleep infinity";
serviceConfig.Type = "oneshot";
};
networking.primaryIPAddress = lib.mkForce "192.168.1.${toString config.virtualisation.test.nodeNumber}";
virtualisation.interfaces.eth1 = {
vlan = 1;
assignIP = false;
};
virtualisation.interfaces.eth2 = {
vlan = 2;
assignIP = false;
};
networking.bridges.br0.interfaces = [
"eth1"
"eth2"
];
networking.interfaces = {
br0.ipv4.addresses = [
{
address = config.networking.primaryIPAddress;
prefixLength = 24;
}
];
};
};
a = {
virtualisation.vlans = [ 1 ];
};
b =
{ config, ... }:
{
virtualisation.vlans = [ 2 ];
networking.primaryIPAddress = lib.mkForce "192.168.1.${toString config.virtualisation.test.nodeNumber}";
networking.interfaces.eth1.ipv4.addresses = lib.mkForce [
{
address = config.networking.primaryIPAddress;
prefixLength = 24;
}
];
};
};
testScript = ''
start_all()
a.wait_for_unit("network.target")
b.wait_for_unit("network.target")
a.succeed("ping -n -w 10 -c 1 bridge >&2")
b.succeed("ping -n -w 10 -c 1 bridge >&2")
a.succeed("ping -n -w 10 -c 1 b >&2")
'';
}
|