about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorArnold Krille <arnold@arnoldarts.de>2016-09-30 10:45:48 +0200
committerArnold Krille <arnold@arnoldarts.de>2016-10-08 22:09:22 +0200
commitf0492bd53c3e78afc429f3b2f3792f13d6352cdb (patch)
treed1cbe22aa632fc1b273399daea1a0f6fbe343032 /nixos/tests
parent2e255a2edddfe5ca0e44f55d6e4bd82737cbb884 (diff)
downloadnixlib-f0492bd53c3e78afc429f3b2f3792f13d6352cdb.tar
nixlib-f0492bd53c3e78afc429f3b2f3792f13d6352cdb.tar.gz
nixlib-f0492bd53c3e78afc429f3b2f3792f13d6352cdb.tar.bz2
nixlib-f0492bd53c3e78afc429f3b2f3792f13d6352cdb.tar.lz
nixlib-f0492bd53c3e78afc429f3b2f3792f13d6352cdb.tar.xz
nixlib-f0492bd53c3e78afc429f3b2f3792f13d6352cdb.tar.zst
nixlib-f0492bd53c3e78afc429f3b2f3792f13d6352cdb.zip
containers: Do not wait for udev for network devices
Test that adding physical devices to containers works, find that network setup
then doesn't work because there is no udev in the container to tell systemd
that the device is present.
Fixed by not depending on the device in the container.

Activate the new container test for release

Bonds, bridges and other network devices need the underlying not as
dependency when used inside the container. Because the device is already
there.

But the address configuration needs the aggregated device itself.
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/containers-physical_interfaces.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/nixos/tests/containers-physical_interfaces.nix b/nixos/tests/containers-physical_interfaces.nix
new file mode 100644
index 000000000000..4a53f8c824f5
--- /dev/null
+++ b/nixos/tests/containers-physical_interfaces.nix
@@ -0,0 +1,66 @@
+
+import ./make-test.nix ({ pkgs, ...} : {
+  name = "containers-physical_interfaces";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ kampfschlaefer ];
+  };
+
+  nodes = {
+    server = { config, pkgs, ... }:
+      {
+        virtualisation.memorySize = 256;
+        virtualisation.vlans = [ 1 ];
+
+        containers.server = {
+          privateNetwork = true;
+          interfaces = [ "eth1" ];
+
+          config = {
+            networking.interfaces.eth1 = {
+              ip4 = [ { address = "10.10.0.1"; prefixLength = 24; } ];
+            };
+            networking.firewall.enable = false;
+          };
+        };
+      };
+    client = { config, pkgs, ... }: {
+      virtualisation.memorySize = 256;
+      virtualisation.vlans = [ 1 ];
+
+      containers.client = {
+        privateNetwork = true;
+        interfaces = [ "eth1" ];
+
+        config = {
+          networking.bridges.br0.interfaces = [ "eth1" ];
+          networking.interfaces.br0 = {
+            ip4 = [ { address = "10.10.0.2"; prefixLength = 24; } ];
+          };
+          networking.firewall.enable = false;
+        };
+      };
+    };
+  };
+
+  testScript = ''
+    startAll;
+
+    $server->waitForUnit("default.target");
+    $server->execute("ip link >&2");
+
+    $server->succeed("ip link show dev eth1 >&2");
+
+    $server->succeed("nixos-container start server");
+    $server->waitForUnit("container\@server");
+    $server->succeed("systemctl -M server list-dependencies network-addresses-eth1.service >&2");
+
+    $server->succeed("nixos-container run server -- ip a show dev eth1 >&2");
+
+    $client->waitForUnit("default.target");
+    $client->succeed("nixos-container start client");
+    $client->waitForUnit("container\@client");
+    $client->succeed("systemctl -M client list-dependencies network-addresses-br0.service >&2");
+    $client->succeed("systemctl -M client status -n 30 -l network-addresses-br0.service");
+    $client->succeed("nixos-container run client -- ping -w 10 -c 1 -n 10.10.0.1");
+  '';
+})