diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e5b6aa..ac6f54b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,41 +1,47 @@ +before_script: + # report CPU info so we can monitor if real KVM becomes available. create /dev/kvm to fool nix + - cat /proc/cpuinfo + - ls -l /dev/kvm || true + - touch /dev/kvm + nixos-intern: image: nixos/nix variables: NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz" script: - - nix-build tests/intern.nix + - nix-build --arg pkgs 'import tests/lib/pkgs.nokvm.nix' tests/intern.nix nixos-extern: image: nixos/nix variables: NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz" script: - - nix-build tests/extern.nix + - nix-build --arg pkgs 'import tests/lib/pkgs.nokvm.nix' tests/extern.nix nixos-clamav: image: nixos/nix variables: NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz" script: - - nix-build tests/clamav.nix + - nix-build --arg pkgs 'import tests/lib/pkgs.nokvm.nix' tests/clamav.nix nixos-unstable-intern: image: nixos/nix variables: NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz" script: - - nix-build tests/intern.nix + - nix-build --arg pkgs 'import tests/lib/pkgs.nokvm.nix' tests/intern.nix nixos-unstable-extern: image: nixos/nix variables: NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz" script: - - nix-build tests/extern.nix + - nix-build --arg pkgs 'import tests/lib/pkgs.nokvm.nix' tests/extern.nix nixos-unstable-clamav: image: nixos/nix variables: NIX_PATH: "nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz" script: - - nix-build tests/clamav.nix + - nix-build --arg pkgs 'import tests/lib/pkgs.nokvm.nix' tests/clamav.nix diff --git a/tests/lib/config.nix b/tests/lib/config.nix index 1d56ad1..b247c66 100644 --- a/tests/lib/config.nix +++ b/tests/lib/config.nix @@ -1,3 +1,11 @@ { security.dhparams.defaultBitSize = 16; # really low for quicker tests + + # For slow non-kvm tests. + # nixos/modules/testing/test-instrumentation.nix also sets this. I don't know if there's a better way than etc to override theirs. + environment.etc."systemd/system.conf.d/bigdefaulttimeout.conf".text = '' + [Manager] + # Allow extremely slow start (default for test-VMs is 5 minutes) + DefaultTimeoutStartSec=15min + ''; } diff --git a/tests/lib/pkgs.nokvm.nix b/tests/lib/pkgs.nokvm.nix new file mode 100644 index 0000000..fa13fde --- /dev/null +++ b/tests/lib/pkgs.nokvm.nix @@ -0,0 +1,31 @@ +let + pkgs = (import { system = builtins.currentSystem; config = {}; }); + patchedMachinePM = pkgs.writeTextFile { + name = "Machine.pm.patched-to-wait-longer-for-vm"; + text = builtins.replaceStrings ["alarm 600;"] ["alarm 1200;"] (builtins.readFile (+"/nixos/lib/test-driver/Machine.pm")); + }; +in +(pkgs // { + qemu_test = with pkgs; stdenv.mkDerivation { + name = "qemu_test_no_kvm"; + buildInputs = [ coreutils qemu_test ]; + inherit qemu_test; + inherit coreutils; + builder = builtins.toFile "builder.sh" '' + PATH=$coreutils/bin:$PATH + mkdir -p $out/bin + cp $qemu_test/bin/* $out/bin/ + ln -sf $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} $out/bin/qemu-kvm + ''; + }; + stdenv = pkgs.stdenv // { + mkDerivation = args: (pkgs.stdenv.mkDerivation (args // ( + pkgs.lib.optionalAttrs (args.name == "nixos-test-driver") { + installPhase = args.installPhase + '' + rm $libDir/Machine.pm + cp ${patchedMachinePM} $libDir/Machine.pm + ''; + } + ))); + }; +})