-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.nix
51 lines (43 loc) · 1.23 KB
/
test.nix
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
{ nixosTest, module, ... }:
nixosTest {
name = "nixos-router";
nodes.router = {
imports = [ module ];
virtualisation.vlans = [ 1 ];
router = {
enable = true;
wanInterface = "eth0";
lanInterface = "eth1";
};
};
nodes.host1 =
{ lib, ... }:
{
virtualisation.vlans = [ 1 ];
# don't use defaults that require internet connectivity
services.resolved.fallbackDns = [ ];
networking = {
useNetworkd = true;
useDHCP = false;
firewall.allowedUDPPorts = [ 5353 ];
interfaces.eth1 = lib.mkForce { };
};
systemd.network.enable = true;
systemd.network.networks."10-eth1" = {
name = "eth1";
DHCP = "yes";
networkConfig.MulticastDNS = true;
};
};
testScript = ''
router.wait_for_unit("network-online.target")
host1.wait_for_unit("network-online.target")
print(router.succeed("networkctl status eth1"))
print(router.succeed("resolvectl"))
print(router.succeed("nft list ruleset"))
print(host1.succeed("networkctl status eth1"))
print(host1.succeed("resolvectl"))
router.wait_until_succeeds("ping -c3 host1.local.")
host1.wait_until_succeeds("ping -c3 router.local.")
'';
}