summaryrefslogtreecommitdiffstats
path: root/nixos/tests/containers-hosts.nix
diff options
context:
space:
mode:
authormontag451 <montag451@laposte.net>2016-12-06 23:32:17 +0100
committerJörg Thalheim <joerg@higgsboson.tk>2016-12-12 09:20:28 +0100
commitea5551b551d0d7f462b7f8e00e2bf86b2412a365 (patch)
tree90bb8e59d2dd9d3d22173c1a28c6055580599d92 /nixos/tests/containers-hosts.nix
parent4889c271cacf72a47dc2f081e6e718980fb80d60 (diff)
containers: fix broken /etc/hosts entries when localAddress contains a netmask
Diffstat (limited to 'nixos/tests/containers-hosts.nix')
-rw-r--r--nixos/tests/containers-hosts.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/nixos/tests/containers-hosts.nix b/nixos/tests/containers-hosts.nix
new file mode 100644
index 000000000000..c7a85f190a5d
--- /dev/null
+++ b/nixos/tests/containers-hosts.nix
@@ -0,0 +1,52 @@
+# Test for NixOS' container support.
+
+import ./make-test.nix ({ pkgs, ...} : {
+ name = "containers-hosts";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ montag451 ];
+ };
+
+ machine =
+ { config, pkgs, lib, ... }:
+ {
+ virtualisation.memorySize = 256;
+ virtualisation.vlans = [];
+
+ networking.bridges.br0.interfaces = [];
+ networking.interfaces.br0 = {
+ ip4 = [ { 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 = {};
+ };
+
+ containers.netmask = {
+ autoStart = true;
+ privateNetwork = true;
+ hostBridge = "br0";
+ localAddress = "10.11.0.1/24";
+
+ config = {};
+ };
+ };
+
+ testScript = ''
+ startAll;
+ $machine->waitForUnit("default.target");
+
+ # Ping the containers using the entries added in /etc/hosts
+ $machine->succeed("ping -n -c 1 simple.containers");
+ $machine->succeed("ping -n -c 1 netmask.containers");
+ '';
+})