summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoey Hewitt <joey@joeyhewitt.com>2019-07-01 11:32:30 -0600
committerJoey Hewitt <joey@joeyhewitt.com>2019-07-07 21:47:09 -0600
commit0e6bb4e898f14af1b476c07cd1da65f4cccc3ee1 (patch)
treee6f34452ae32220fd9952b1cad403c9259fd1b04 /tests
parent05d963e751070f6a5b4a831b075176a7bdae0b38 (diff)
workaround GitLab CI KVM issue
Their CI environment currently doesn't have KVM. This commit should be reverted when/if they do, for much better CI speed. You can still run tests locally on your KVM-enabled machine as documented on the wiki. Workaround on GitLab is several pieces (injected through .gitlab-ci.yml): - Make a /dev/kvm file so that nix thinks we have "kvm" system feature and proceeds with executing the tests. - Inject a QEMU package that replaces qemu-kvm with a full emulator. - Monkey-patch the test script to wait longer for the VM to boot, since it's slow on full emulation. 1200 seconds, double the previous value. The patch method is not bulletproof, but better than maintaining forks of nixpkgs. - Set systemd's DefaultTimeoutStartSec=15min, so nix's "backdoor" test service doesn't time out on the slow boot.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/config.nix8
-rw-r--r--tests/lib/pkgs.nokvm.nix31
2 files changed, 39 insertions, 0 deletions
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 <nixpkgs> { 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 (<nixpkgs>+"/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
+ '';
+ }
+ )));
+ };
+})