about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/aszlig/i3.nix41
-rw-r--r--tests/default.nix19
-rw-r--r--tests/labnet/heinrich.nix51
-rw-r--r--tests/make-test.nix30
-rw-r--r--tests/richi235/multipath-vpn.nix189
5 files changed, 330 insertions, 0 deletions
diff --git a/tests/aszlig/i3.nix b/tests/aszlig/i3.nix
new file mode 100644
index 00000000..3c5a5c0c
--- /dev/null
+++ b/tests/aszlig/i3.nix
@@ -0,0 +1,41 @@
+{ pkgs, ... }:
+
+{
+  name = "i3";
+
+  machine = { lib, ... }: {
+    imports = [
+      "${import ../../nixpkgs-path.nix}/nixos/tests/common/x11.nix"
+    ];
+
+    vuizvui.user.aszlig.profiles.base.enable = true;
+
+    vuizvui.user.aszlig.services.i3 = {
+      enable = true;
+
+      workspaces."1" = {
+        label = "first";
+        assign = lib.singleton { class = "^test\$"; };
+      };
+    };
+
+    services.xserver.windowManager.default = lib.mkForce "i3";
+    /* XXX */
+    fonts = {
+      enableCoreFonts = true;
+      enableFontDir = true;
+      enableGhostscriptFonts = true;
+      fonts = [
+        pkgs.dosemu_fonts
+        pkgs.liberation_ttf
+      ];
+    };
+    /* !XXX */
+  };
+
+  testScript = { nodes, ... }: ''
+    $machine->waitForX;
+    $machine->sleep(20);
+    $machine->screenshot("i3");
+  '';
+}
diff --git a/tests/default.nix b/tests/default.nix
new file mode 100644
index 00000000..77fb3073
--- /dev/null
+++ b/tests/default.nix
@@ -0,0 +1,19 @@
+{ system ? builtins.currentSystem, ... }:
+
+let
+  callTest = path: import ./make-test.nix (import path) {
+    inherit system;
+  };
+
+in {
+  aszlig = {
+    i3 = callTest ./aszlig/i3.nix;
+  };
+  labnet = {
+    heinrich = callTest ./labnet/heinrich.nix;
+  };
+  richi235 = {
+    # Currently broken
+    #multipath-vpn = callTest ./richi235/multipath-vpn.nix;
+  };
+}
diff --git a/tests/labnet/heinrich.nix b/tests/labnet/heinrich.nix
new file mode 100644
index 00000000..a7839c42
--- /dev/null
+++ b/tests/labnet/heinrich.nix
@@ -0,0 +1,51 @@
+{
+  name = "heinrich";
+
+  nodes = let
+    common = { lib, ... }: {
+      networking.useNetworkd = true;
+      systemd.network.netdevs."40-eth0".netdevConfig = {
+        Name = "eth0";
+        Kind = "dummy";
+      };
+    };
+  in {
+    heinrich = {
+      imports = [ common (import ../../machines {}).labnet.heinrich.config ];
+      virtualisation.vlans = [ 1 8 14 ];
+      vuizvui.machines.heinrich.internalInterface = "eth1";
+      vuizvui.machines.heinrich.externalInterface = "eth2";
+    };
+    hotelturm = { lib, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 8 ];
+      networking.useDHCP = false;
+      networking.interfaces.eth1.ip4 = lib.singleton {
+        address = "10.11.77.16";
+        prefixLength = 24;
+      };
+    };
+    moritz = { lib, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 14 ];
+      networking.useDHCP = false;
+      networking.interfaces.eth1.ip4 = lib.singleton {
+        address = "192.168.0.1";
+        prefixLength = 24;
+      };
+    };
+    client = {
+      imports = [ common ];
+      virtualisation.vlans = [ 1 ];
+    };
+  };
+
+  testScript = ''
+    startAll;
+    $heinrich->waitForUnit("dnsmasq.service");
+    $client->waitForUnit("network-interfaces.target");
+    $client->waitForUnit("network.target");
+
+    $client->succeed("ip addr >&2");
+  '';
+}
diff --git a/tests/make-test.nix b/tests/make-test.nix
new file mode 100644
index 00000000..d98ff87f
--- /dev/null
+++ b/tests/make-test.nix
@@ -0,0 +1,30 @@
+f: { system ? builtins.currentSystem, ... } @ args: let
+  nixpkgsPath = import ../nixpkgs-path.nix;
+
+  lib = import "${nixpkgsPath}/lib";
+
+  testLib = import "${nixpkgsPath}/nixos/lib/testing.nix" {
+    inherit system;
+  };
+
+  pkgs = import nixpkgsPath { inherit system; };
+
+  testArgs = if builtins.isFunction f then f (args // {
+    pkgs = pkgs // {
+      vuizvui = import ../pkgs { inherit pkgs; };
+    };
+  }) else f;
+
+  nodes = testArgs.nodes or (if testArgs ? machine then {
+    inherit (testArgs) machine;
+  } else {});
+
+  injectCommon = name: conf: {
+    imports = [ conf ] ++ import ../modules/module-list.nix;
+  };
+
+  testArgsWithCommon = removeAttrs testArgs [ "machine" ] // {
+    nodes = lib.mapAttrs injectCommon nodes;
+  };
+
+in testLib.makeTest testArgsWithCommon
diff --git a/tests/richi235/multipath-vpn.nix b/tests/richi235/multipath-vpn.nix
new file mode 100644
index 00000000..3595b074
--- /dev/null
+++ b/tests/richi235/multipath-vpn.nix
@@ -0,0 +1,189 @@
+{
+  name = "multipath-test";
+
+  nodes = let
+    common = { lib, ... }: {
+      networking.firewall.enable = false;
+      networking.useNetworkd = true;
+      systemd.network.netdevs."40-eth0".netdevConfig = {
+        Name = "eth0";
+        Kind = "dummy";
+      };
+    };
+
+  in {
+    client = { lib, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 10 ];
+      networking.defaultGateway = "42.0.0.1";
+      networking.interfaces.eth1.ip4 = lib.singleton {
+        address = "42.0.0.2";
+        prefixLength = 8;
+      };
+    };
+    mtc = { lib, nodes, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 1 2 10 ];
+      networking.interfaces.eth1.ip4 = lib.mkForce (lib.singleton {
+        address = "1.0.0.2";
+        prefixLength = 8;
+      });
+      networking.interfaces.eth2.ip4 = lib.mkForce (lib.singleton {
+        address = "2.0.0.2";
+        prefixLength = 8;
+      });
+      networking.interfaces.eth3.ip4 = lib.mkForce (lib.singleton {
+        address = "42.0.0.1";
+        prefixLength = 8;
+      });
+      systemd.network.networks."40-eth1".routes = lib.singleton {
+        routeConfig.Gateway = "1.0.0.1";
+        routeConfig.Destination = "10.0.0.0/8";
+      };
+      systemd.network.networks."40-eth2".routes = lib.singleton {
+        routeConfig.Gateway = "2.0.0.1";
+        routeConfig.Destination = "11.0.0.0/8";
+      };
+      vuizvui.services.multipath-vpn.client.enable = true;
+      vuizvui.services.multipath-vpn.client.links.vlan1 = {
+        interface = "eth1";
+        destAddress = "10.0.0.1";
+      };
+      vuizvui.services.multipath-vpn.client.links.vlan2 = {
+        interface = "eth2";
+        destAddress = "11.0.0.1";
+      };
+      vuizvui.services.multipath-vpn.client.tun = {
+        ip = "192.168.66.2";
+        mask = 24;
+      };
+      vuizvui.services.multipath-vpn.client.route = {
+        network = "0.0.0.0";
+        mask = 0;
+        gateway = "192.168.66.1";
+      };
+    };
+    relay1 = { lib, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 1 3 ];
+      networking.useDHCP = false;
+      networking.interfaces.eth1.ip4 = lib.mkForce (lib.singleton {
+        address = "1.0.0.1";
+        prefixLength = 8;
+      });
+      networking.interfaces.eth2.ip4 = lib.mkForce (lib.singleton {
+        address = "10.0.0.2";
+        prefixLength = 8;
+      });
+      systemd.network.networks."40-eth2".routes = lib.singleton {
+        routeConfig.Gateway = "10.0.0.1";
+        routeConfig.Destination = "10.0.0.0/8";
+      };
+      networking.nat.enable = true;
+      networking.nat.internalInterfaces = [ "eth1" ];
+      networking.nat.externalInterface = "eth2";
+    };
+    relay2 = { lib, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 2 4 ];
+      networking.useDHCP = false;
+      networking.interfaces.eth1.ip4 = lib.mkForce (lib.singleton {
+        address = "2.0.0.1";
+        prefixLength = 8;
+      });
+      networking.interfaces.eth2.ip4 = lib.mkForce (lib.singleton {
+        address = "11.0.0.2";
+        prefixLength = 8;
+      });
+      systemd.network.networks."40-eth2".routes = lib.singleton {
+        routeConfig.Gateway = "11.0.0.1";
+        routeConfig.Destination = "11.0.0.0/8";
+      };
+      networking.nat.enable = true;
+      networking.nat.internalInterfaces = [ "eth1" ];
+      networking.nat.externalInterface = "eth2";
+    };
+    mts = { lib, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 3 4 5 ];
+      networking.interfaces.eth1.ip4 = lib.mkForce (lib.singleton {
+        address = "10.0.0.1";
+        prefixLength = 8;
+      });
+      networking.interfaces.eth2.ip4 = lib.mkForce (lib.singleton {
+        address = "11.0.0.1";
+        prefixLength = 8;
+      });
+      networking.interfaces.eth3.ip4 = lib.mkForce (lib.singleton {
+        address = "6.6.6.42";
+        prefixLength = 8;
+      });
+      networking.nat.enable = true;
+      #networking.nat.internalInterfaces = [ "tun0" ];
+      networking.nat.externalInterface = "eth3";
+      vuizvui.services.multipath-vpn.server.enable = true;
+      vuizvui.services.multipath-vpn.server.links.vlan3 = {
+        interface = "eth1";
+        destAddress = "0"; # XXX
+        destPort = 0; # XXX
+      };
+      vuizvui.services.multipath-vpn.server.links.vlan4 = {
+        interface = "eth2";
+        destAddress = "0"; # XXX
+        destPort = 0; # XXX
+      };
+      vuizvui.services.multipath-vpn.server.tun = {
+        ip = "192.168.66.1";
+        mask = 24;
+      };
+      vuizvui.services.multipath-vpn.server.route = {
+        #network = "192.168.0.0";
+        #network = "6.0.0.0";
+        #mask = 8;
+        network = "0.0.0.0";
+        mask = 0;
+        gateway = "192.168.66.2";
+      };
+    };
+    zs = { lib, ... }: {
+      imports = [ common ];
+      virtualisation.vlans = [ 5 ];
+      networking.interfaces.eth1.ip4 = lib.mkForce (lib.singleton {
+        address = "6.6.6.23";
+        prefixLength = 8;
+      });
+    };
+  };
+
+  testScript = { nodes, ... }: ''
+    startAll;
+    $mtc->waitForUnit("multipath-vpn-client.service");
+    $mts->waitForUnit("multipath-vpn-server.service");
+
+    $mtc->sleep(30);
+
+    subtest "test network topology", sub {
+      $mtc->succeed("ping -c1 10.0.0.1 >&2");
+      $mtc->succeed("ping -c1 11.0.0.1 >&2");
+      $mts->succeed("ping -c1 6.6.6.23 >&2");
+    };
+
+    subtest "test tunnel connectivity", sub {
+      $client->execute("ifconfig >&2");
+      $client->execute("ip route >&2");
+      $zs->execute("ifconfig >&2");
+      $zs->execute("ip route >&2");
+
+      $mtc->execute("ifconfig >&2");
+      $mtc->execute("ip route >&2");
+      $mts->execute("ifconfig >&2");
+      $mts->execute("ip route >&2");
+
+      $mtc->succeed("ping -c1 192.168.66.1 >&2");
+      $mtc->succeed("ping -c1 6.6.6.23 >&2");
+
+      #$client->succeed("ping -c1 192.168.66.1 >&2");
+      $client->succeed("ping -c1 6.6.6.23 >&2");
+    };
+  '';
+}