summary refs log tree commit diff
path: root/nixos/tests/wireguard/namespaces.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2020-04-26 14:24:18 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2020-04-29 23:10:53 +0200
commit41bd6d2614749d12ce5ded3e991555b56ea6b2dc (patch)
treecc021e305630cf83b05d7fde5831552aa85fc2ea /nixos/tests/wireguard/namespaces.nix
parentf56459f7ec83c8afb7c355200c502aa8b0c8affe (diff)
downloadnixpkgs-41bd6d2614749d12ce5ded3e991555b56ea6b2dc.tar
nixpkgs-41bd6d2614749d12ce5ded3e991555b56ea6b2dc.tar.gz
nixpkgs-41bd6d2614749d12ce5ded3e991555b56ea6b2dc.tar.bz2
nixpkgs-41bd6d2614749d12ce5ded3e991555b56ea6b2dc.tar.lz
nixpkgs-41bd6d2614749d12ce5ded3e991555b56ea6b2dc.tar.xz
nixpkgs-41bd6d2614749d12ce5ded3e991555b56ea6b2dc.tar.zst
nixpkgs-41bd6d2614749d12ce5ded3e991555b56ea6b2dc.zip
nixos/wireguard: test against multiple kernel versions
When testing WireGuard updates, I usually run the VM-tests with
different kernels to make sure we're not introducing accidental
regressions for e.g. older kernels.

I figured that we should automate this process to ensure continuously
that WireGuard works fine on several kernels.

For now I decided to test the latest LTS version (5.4) and
the latest kernel (currently 5.6). We can add more kernels in the
future, however this seems to significantly slow down evaluation and
time.

The list can be customized by running a command like this:

   nix-build nixos/tests/wireguard --arg kernelVersionsToTest '["4.19"]'

The `kernelPackages` argument in the tests is null by default to make
sure that it's still possible to invoke the test-files directly. In that
case the default kernel of NixOS (currently 5.4) is used.
Diffstat (limited to 'nixos/tests/wireguard/namespaces.nix')
-rw-r--r--nixos/tests/wireguard/namespaces.nix8
1 files changed, 7 insertions, 1 deletions
diff --git a/nixos/tests/wireguard/namespaces.nix b/nixos/tests/wireguard/namespaces.nix
index c8a4e3bb52a..c47175ceafc 100644
--- a/nixos/tests/wireguard/namespaces.nix
+++ b/nixos/tests/wireguard/namespaces.nix
@@ -1,3 +1,5 @@
+{ kernelPackages ? null }:
+
 let
   listenPort = 12345;
   socketNamespace = "foo";
@@ -13,7 +15,7 @@ let
 
 in
 
-import ../make-test-python.nix ({ pkgs, ...} : {
+import ../make-test-python.nix ({ pkgs, lib, ... } : {
   name = "wireguard-with-namespaces";
   meta = with pkgs.stdenv.lib.maintainers; {
     maintainers = [ asymmetric ];
@@ -23,6 +25,7 @@ import ../make-test-python.nix ({ pkgs, ...} : {
     # interface should be created in the socketNamespace
     # and not moved from there
     peer0 = pkgs.lib.attrsets.recursiveUpdate node {
+      boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
       networking.wireguard.interfaces.wg0 = {
         preSetup = ''
           ip netns add ${socketNamespace}
@@ -33,6 +36,7 @@ import ../make-test-python.nix ({ pkgs, ...} : {
     # interface should be created in the init namespace
     # and moved to the interfaceNamespace
     peer1 = pkgs.lib.attrsets.recursiveUpdate node {
+      boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
       networking.wireguard.interfaces.wg0 = {
         preSetup = ''
           ip netns add ${interfaceNamespace}
@@ -43,6 +47,7 @@ import ../make-test-python.nix ({ pkgs, ...} : {
     # interface should be created in the socketNamespace
     # and moved to the interfaceNamespace
     peer2 = pkgs.lib.attrsets.recursiveUpdate node {
+      boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
       networking.wireguard.interfaces.wg0 = {
         preSetup = ''
           ip netns add ${socketNamespace}
@@ -54,6 +59,7 @@ import ../make-test-python.nix ({ pkgs, ...} : {
     # interface should be created in the socketNamespace
     # and moved to the init namespace
     peer3 = pkgs.lib.attrsets.recursiveUpdate node {
+      boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
       networking.wireguard.interfaces.wg0 = {
         preSetup = ''
           ip netns add ${socketNamespace}