diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2020-10-21 00:41:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-21 00:41:01 +0200 |
commit | f6cd17269ea0076631938886d8ed4764c71d7731 (patch) | |
tree | 455945f1c770ac8f325bdd638d7015de5fc98a41 /nixos | |
parent | 6e5ccaa34f381d557e8df9f049b69218afd16ad8 (diff) | |
parent | 16a7ff5b867f6e9cb615eac7a136421a197921c0 (diff) |
Merge pull request #49403 from andir/qemu_test_reduce_closure
qemu_test: disable features that are not needed for tests (closure 641 -> 335.3M)
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/doc/manual/development/running-nixos-tests-interactively.xml | 4 | ||||
-rw-r--r-- | nixos/lib/testing-python.nix | 20 | ||||
-rw-r--r-- | nixos/modules/testing/test-instrumentation.nix | 4 | ||||
-rw-r--r-- | nixos/modules/virtualisation/qemu-guest-agent.nix | 7 |
4 files changed, 26 insertions, 9 deletions
diff --git a/nixos/doc/manual/development/running-nixos-tests-interactively.xml b/nixos/doc/manual/development/running-nixos-tests-interactively.xml index a11a9382764d..a6044d5f89e8 100644 --- a/nixos/doc/manual/development/running-nixos-tests-interactively.xml +++ b/nixos/doc/manual/development/running-nixos-tests-interactively.xml @@ -9,7 +9,7 @@ The test itself can be run interactively. This is particularly useful when developing or debugging a test: <screen> -<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver +<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive <prompt>$ </prompt>./result/bin/nixos-test-driver starting VDE switch for network 1 <prompt>></prompt> @@ -30,7 +30,7 @@ starting VDE switch for network 1 <para> To just start and experiment with the VMs, run: <screen> -<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver +<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive <prompt>$ </prompt>./result/bin/nixos-run-vms </screen> The script <command>nixos-run-vms</command> starts the virtual machines diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index 498f97336c02..302c7f78bf8e 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -17,9 +17,9 @@ rec { inherit pkgs; - testDriver = let + mkTestDriver = let testDriverScript = ./test-driver/test-driver.py; - in stdenv.mkDerivation { + in qemu_pkg: stdenv.mkDerivation { name = "nixos-test-driver"; nativeBuildInputs = [ makeWrapper ]; @@ -47,10 +47,12 @@ rec { # TODO: copy user script part into this file (append) wrapProgram $out/bin/nixos-test-driver \ - --prefix PATH : "${lib.makeBinPath [ qemu_test vde2 netpbm coreutils ]}" \ + --prefix PATH : "${lib.makeBinPath [ qemu_pkg vde2 netpbm coreutils ]}" \ ''; }; + testDriver = mkTestDriver qemu_test; + testDriverInteractive = mkTestDriver qemu_kvm; # Run an automated test suite in the given virtual network. # `driver' is the script that runs the network. @@ -113,7 +115,11 @@ rec { # Generate convenience wrappers for running the test driver # interactively with the specified network, and for starting the # VMs from the command line. - driver = let warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; in warn (runCommand testDriverName + driver = testDriver: + let + warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; + in + warn (runCommand testDriverName { buildInputs = [ makeWrapper]; testScript = testScript'; preferLocalBuild = true; @@ -148,7 +154,7 @@ rec { meta = (drv.meta or {}) // t.meta; }; - test = passMeta (runTests driver); + test = passMeta (runTests (driver testDriver)); nodeNames = builtins.attrNames nodes; invalidNodeNames = lib.filter @@ -165,7 +171,9 @@ rec { '' else test // { - inherit nodes driver test; + inherit nodes test; + driver = driver testDriver; + driverInteractive = driver testDriverInteractive; }; runInMachine = diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index c0ec76e8a3a3..dbbcb0bed5b0 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -116,6 +116,10 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; users.users.root.initialHashedPassword = mkOverride 150 ""; services.xserver.displayManager.job.logToJournal = true; + + # Make sure we use the Guest Agent from the QEMU package for testing + # to reduce the closure size required for the tests. + services.qemuGuest.package = pkgs.qemu_test.ga; }; } diff --git a/nixos/modules/virtualisation/qemu-guest-agent.nix b/nixos/modules/virtualisation/qemu-guest-agent.nix index 665224e35d8c..6a735f451a7e 100644 --- a/nixos/modules/virtualisation/qemu-guest-agent.nix +++ b/nixos/modules/virtualisation/qemu-guest-agent.nix @@ -12,6 +12,11 @@ in { default = false; description = "Whether to enable the qemu guest agent."; }; + package = mkOption { + type = types.package; + default = pkgs.qemu.ga; + description = "The QEMU guest agent package."; + }; }; config = mkIf cfg.enable ( @@ -25,7 +30,7 @@ in { systemd.services.qemu-guest-agent = { description = "Run the QEMU Guest Agent"; serviceConfig = { - ExecStart = "${pkgs.qemu.ga}/bin/qemu-ga"; + ExecStart = "${cfg.package}/bin/qemu-ga"; Restart = "always"; RestartSec = 0; }; |