diff --git a/nixos/tests/k3s/default.nix b/nixos/tests/k3s/default.nix index 07d93c41c7a..e168f8233c7 100644 --- a/nixos/tests/k3s/default.nix +++ b/nixos/tests/k3s/default.nix @@ -1,9 +1,13 @@ { system ? builtins.currentSystem , pkgs ? import ../../.. { inherit system; } +, lib ? pkgs.lib }: +let + allK3s = lib.filterAttrs (n: _: lib.strings.hasPrefix "k3s_" n) pkgs; +in { # Run a single node k3s cluster and verify a pod can run - single-node = import ./single-node.nix { inherit system pkgs; }; + single-node = lib.mapAttrs (_: k3s: import ./single-node.nix { inherit system pkgs k3s; }) allK3s; # Run a multi-node k3s cluster and verify pod networking works across nodes - multi-node = import ./multi-node.nix { inherit system pkgs; }; + multi-node = lib.mapAttrs (_: k3s: import ./multi-node.nix { inherit system pkgs k3s; }) allK3s; } diff --git a/nixos/tests/k3s/multi-node.nix b/nixos/tests/k3s/multi-node.nix index 9a6c7fd4657..932b4639b39 100644 --- a/nixos/tests/k3s/multi-node.nix +++ b/nixos/tests/k3s/multi-node.nix @@ -1,4 +1,4 @@ -import ../make-test-python.nix ({ pkgs, lib, ... }: +import ../make-test-python.nix ({ pkgs, lib, k3s, ... }: let imageEnv = pkgs.buildEnv { name = "k3s-pause-image-env"; @@ -39,7 +39,7 @@ import ../make-test-python.nix ({ pkgs, lib, ... }: tokenFile = pkgs.writeText "token" "p@s$w0rd"; in { - name = "k3s-multi-node"; + name = "${k3s.name}-multi-node"; nodes = { server = { pkgs, ... }: { @@ -52,7 +52,7 @@ import ../make-test-python.nix ({ pkgs, lib, ... }: inherit tokenFile; enable = true; role = "server"; - package = pkgs.k3s; + package = k3s; clusterInit = true; extraFlags = builtins.toString [ "--disable" "coredns" diff --git a/nixos/tests/k3s/single-node.nix b/nixos/tests/k3s/single-node.nix index a95fa4a031e..c120f461ddc 100644 --- a/nixos/tests/k3s/single-node.nix +++ b/nixos/tests/k3s/single-node.nix @@ -1,4 +1,4 @@ -import ../make-test-python.nix ({ pkgs, lib, ... }: +import ../make-test-python.nix ({ pkgs, lib, k3s, ... }: let imageEnv = pkgs.buildEnv { name = "k3s-pause-image-env"; @@ -24,7 +24,7 @@ import ../make-test-python.nix ({ pkgs, lib, ... }: ''; in { - name = "k3s"; + name = "${k3s.name}-single-node"; meta = with pkgs.lib.maintainers; { maintainers = [ euank ]; }; @@ -38,7 +38,7 @@ import ../make-test-python.nix ({ pkgs, lib, ... }: services.k3s.enable = true; services.k3s.role = "server"; - services.k3s.package = pkgs.k3s; + services.k3s.package = k3s; # Slightly reduce resource usage services.k3s.extraFlags = builtins.toString [ "--disable" "coredns" diff --git a/pkgs/applications/networking/cluster/k3s/1_23/default.nix b/pkgs/applications/networking/cluster/k3s/1_23/default.nix index 3865cb0a06e..72fbe89dd6b 100644 --- a/pkgs/applications/networking/cluster/k3s/1_23/default.nix +++ b/pkgs/applications/networking/cluster/k3s/1_23/default.nix @@ -320,8 +320,7 @@ buildGoModule rec { # Fix-Me: Needs to be adapted specifically for 1.23 # passthru.updateScript = ./update.sh; - # Fix-Me: Needs to be adapted specifically for 1.23 - # passthru.tests = { inherit (nixosTests) k3s-single-node k3s-single-node-docker; }; + passthru.tests = k3s.passthru.mkTests k3sVersion; meta = baseMeta; } diff --git a/pkgs/applications/networking/cluster/k3s/1_24/default.nix b/pkgs/applications/networking/cluster/k3s/1_24/default.nix index 18e0258432e..11037db5b6d 100644 --- a/pkgs/applications/networking/cluster/k3s/1_24/default.nix +++ b/pkgs/applications/networking/cluster/k3s/1_24/default.nix @@ -322,8 +322,7 @@ buildGoModule rec { # Fix-Me: Needs to be adapted specifically for 1.24 # passthru.updateScript = ./update.sh; - # Fix-Me: Needs to be adapted specifically for 1.24 - # passthru.tests = nixosTests.k3s; + passthru.tests = k3s.passthru.mkTests k3sVersion; meta = baseMeta; } diff --git a/pkgs/applications/networking/cluster/k3s/1_25/default.nix b/pkgs/applications/networking/cluster/k3s/1_25/default.nix index dc34821fb25..b62eec69285 100644 --- a/pkgs/applications/networking/cluster/k3s/1_25/default.nix +++ b/pkgs/applications/networking/cluster/k3s/1_25/default.nix @@ -322,8 +322,7 @@ buildGoModule rec { # Fix-Me: Needs to be adapted specifically for 1.25 # passthru.updateScript = ./update.sh; - # Fix-Me: Needs to be adapted specifically for 1.25 - # passthru.tests = nixosTests.k3s; + passthru.tests = k3s.passthru.mkTests k3sVersion; meta = baseMeta; } diff --git a/pkgs/applications/networking/cluster/k3s/1_26/default.nix b/pkgs/applications/networking/cluster/k3s/1_26/default.nix index 144e1116bb1..cef2355a3da 100644 --- a/pkgs/applications/networking/cluster/k3s/1_26/default.nix +++ b/pkgs/applications/networking/cluster/k3s/1_26/default.nix @@ -319,7 +319,14 @@ buildGoModule rec { passthru.updateScript = ./update.sh; - passthru.tests = nixosTests.k3s; + passthru.mkTests = version: + let k3s_version = "k3s_" + lib.replaceStrings ["."] ["_"] (lib.versions.majorMinor version); + in { + single-node = nixosTests.k3s.single-node.${k3s_version}; + multi-node = nixosTests.k3s.multi-node.${k3s_version}; + }; + passthru.tests = passthru.mkTests k3sVersion; + meta = baseMeta; }