1import ./make-test-python.nix (
2 { pkgs, lib, ... }:
3 {
4 name = "containers-hosts";
5 meta = {
6 maintainers = with lib.maintainers; [ montag451 ];
7 };
8
9 nodes.machine =
10 { lib, ... }:
11 {
12 virtualisation.vlans = [ ];
13
14 networking.bridges.br0.interfaces = [ ];
15 networking.interfaces.br0.ipv4.addresses = [
16 {
17 address = "10.11.0.254";
18 prefixLength = 24;
19 }
20 ];
21
22 # Force /etc/hosts to be the only source for host name resolution
23 environment.etc."nsswitch.conf".text = lib.mkForce ''
24 hosts: files
25 '';
26
27 containers.simple = {
28 autoStart = true;
29 privateNetwork = true;
30 localAddress = "10.10.0.1";
31 hostAddress = "10.10.0.254";
32
33 config = { };
34 };
35
36 containers.netmask = {
37 autoStart = true;
38 privateNetwork = true;
39 hostBridge = "br0";
40 localAddress = "10.11.0.1/24";
41
42 config = { };
43 };
44 };
45
46 testScript = ''
47 start_all()
48 machine.wait_for_unit("default.target")
49
50 with subtest("Ping the containers using the entries added in /etc/hosts"):
51 for host in "simple.containers", "netmask.containers":
52 machine.succeed(f"ping -n -c 1 {host}")
53 '';
54 }
55)