blob: 7ec1209c2fbf02f986d00279bde80e4bd16d75bd (
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
|
{ pkgs, lib, ... }:
{
name = "containers-hosts";
meta = {
maintainers = with lib.maintainers; [ montag451 ];
};
nodes.machine =
{ lib, ... }:
{
virtualisation.vlans = [ ];
networking.bridges.br0.interfaces = [ ];
networking.interfaces.br0.ipv4.addresses = [
{
address = "10.11.0.254";
prefixLength = 24;
}
];
# Force /etc/hosts to be the only source for host name resolution
environment.etc."nsswitch.conf".text = lib.mkForce ''
hosts: files
'';
containers.simple = {
autoStart = true;
privateNetwork = true;
localAddress = "10.10.0.1";
hostAddress = "10.10.0.254";
config = {
nix.enable = false; # disabled by default on the test's host. See all-tests.nix / tag(no-nix-by-default)
};
};
containers.netmask = {
autoStart = true;
privateNetwork = true;
hostBridge = "br0";
localAddress = "10.11.0.1/24";
config = {
nix.enable = false; # disabled by default on the test's host. See all-tests.nix / tag(no-nix-by-default)
};
};
};
testScript = ''
start_all()
machine.wait_for_unit("default.target")
with subtest("Ping the containers using the entries added in /etc/hosts"):
for host in "simple.containers", "netmask.containers":
machine.succeed(f"ping -n -c 1 {host}")
'';
}
|