From 779c71047611c89515b1497cd2581807f8eaac37 Mon Sep 17 00:00:00 2001 From: r-vdp Date: Wed, 11 Dec 2024 09:38:55 +0100 Subject: [PATCH] nixos/switch-test: use the runTest handler to improve eval performance The newer runTest handler uses a single nixpkgs instance to eval all the specialisations, reducing the memory usage and eval time of the test drastically compared to handleTest which creates a new nixpkgs instance for every specialisation. --- nixos/tests/all-tests.nix | 10 ++++++++-- nixos/tests/switch-test.nix | 7 +++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 927382091e72..6119b7060318 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -965,8 +965,14 @@ in { swapspace = handleTestOn ["aarch64-linux" "x86_64-linux"] ./swapspace.nix {}; sway = handleTest ./sway.nix {}; swayfx = handleTest ./swayfx.nix {}; - switchTest = handleTest ./switch-test.nix { ng = false; }; - switchTestNg = handleTest ./switch-test.nix { ng = true; }; + switchTest = runTest { + imports = [ ./switch-test.nix ]; + defaults.system.switch.enableNg = false; + }; + switchTestNg = runTest { + imports = [ ./switch-test.nix ]; + defaults.system.switch.enableNg = true; + }; sx = handleTest ./sx.nix {}; sympa = handleTest ./sympa.nix {}; syncthing = handleTest ./syncthing.nix {}; diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix index c48a3963a79e..1f5574cfd704 100644 --- a/nixos/tests/switch-test.nix +++ b/nixos/tests/switch-test.nix @@ -1,6 +1,7 @@ # Test configuration switching. +{ lib, pkgs, ...}: -import ./make-test-python.nix ({ lib, pkgs, ng, ...} : let +let # Simple service that can either be socket-activated or that will # listen on port 1234 if not socket-activated. @@ -48,8 +49,6 @@ in { nodes = { machine = { pkgs, lib, ... }: { - system.switch.enableNg = ng; - environment.systemPackages = [ pkgs.socat ]; # for the socket activation stuff users.mutableUsers = false; @@ -1455,4 +1454,4 @@ in { assert_lacks(out, "\nstarting the following units:") assert_lacks(out, "the following new units were started:") ''; -}) +}