tests: optimize building multiple tests at once
The result of `import tests.nix {}` is now an attrset of tests.
This makes it easier and more efficient to evaluate or build multiple
tests in one call to `nix build`.
Simplify tests.nix by removing the large module args scope in favor of
self-contained scenario module definitions.
Add CPU core and memory size defaults to the test configuration to
enable building tests without `run-tests.sh`.
Add the following top-level args to tests.nix:
- `extraScenarios` to provide a nix-level way to define extra scenarios.
- `pkgs` to allow building tests with custom pkgs or systems.
This commit is contained in:
parent
9ca52af523
commit
44439e2a81
5 changed files with 59 additions and 32 deletions
|
|
@ -84,6 +84,6 @@ if [[ ! ($containerBin && $(realpath $containerBin) == *extra-container-0.6*) ]]
|
|||
fi
|
||||
|
||||
read -d '' src <<EOF || true
|
||||
(import "$scriptDir/tests.nix" { scenario = "$scenario"; }).container
|
||||
((import "$scriptDir/tests.nix" {}).getTest "$scenario").container
|
||||
EOF
|
||||
exec extra-container $containerCommand -E "$src" "$@"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
pkgs:
|
||||
let
|
||||
pythonTesting = import "${toString pkgs.path}/nixos/lib/testing-python.nix" {
|
||||
system = builtins.currentSystem;
|
||||
system = pkgs.stdenv.hostPlatform.system;
|
||||
inherit pkgs;
|
||||
};
|
||||
in
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
pkgs:
|
||||
let
|
||||
pkgs = import <nixpkgs> { config = {}; overlays = []; };
|
||||
makeVM = import ./make-test-vm.nix pkgs;
|
||||
inherit (pkgs) lib;
|
||||
in
|
||||
|
||||
name: testConfig:
|
||||
{
|
||||
vm = makeVM {
|
||||
|
|
@ -9,8 +11,15 @@ name: testConfig:
|
|||
|
||||
machine = {
|
||||
imports = [ testConfig ];
|
||||
# Needed because duplicity requires 270 MB of free temp space, regardless of backup size
|
||||
virtualisation.diskSize = 1024;
|
||||
virtualisation = {
|
||||
# Needed because duplicity requires 270 MB of free temp space, regardless of backup size
|
||||
diskSize = 1024;
|
||||
|
||||
# Min. 800 MiB needed to avoid 'out of memory' errors
|
||||
memorySize = lib.mkDefault 2048;
|
||||
|
||||
cores = lib.mkDefault 2;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = nodes: let
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue