summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorRaito Bezarius <masterancpp@gmail.com>2023-10-27 13:32:04 +0200
committerRaito Bezarius <masterancpp@gmail.com>2023-10-29 12:45:00 +0100
commitc90219633c40eaeb9ca69c7a8cea75123a13d596 (patch)
tree48acf64031415cad8f42100fe99effb402c3bd19 /nixos
parenta0dc17bd572018e9a4c6f77e30583f5fc292c5d5 (diff)
nixos/tests/nixos-test-driver: test timeout failures
We test that the test framework timeouts are working as expected.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/all-tests.nix8
-rw-r--r--nixos/tests/nixos-test-driver/timeout.nix15
2 files changed, 23 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 1c8ee32428eac..2b50c09872ea8 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -90,6 +90,14 @@ in {
     lib-extend = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./nixos-test-driver/lib-extend.nix {};
     node-name = runTest ./nixos-test-driver/node-name.nix;
     busybox = runTest ./nixos-test-driver/busybox.nix;
+    driver-timeout = pkgs.runCommand "ensure-timeout-induced-failure" {
+      failed = pkgs.testers.testBuildFailure ((runTest ./nixos-test-driver/timeout.nix).config.rawTestDerivation);
+    } ''
+      grep -F "timeout reached; test terminating" $failed/testBuildFailure.log
+      # The program will always be terminated by SIGTERM (143) if it waits for the deadline thread.
+      [[ 143 = $(cat $failed/testBuildFailure.exit) ]]
+      touch $out
+    '';
   };
 
   # NixOS vm tests and non-vm unit tests
diff --git a/nixos/tests/nixos-test-driver/timeout.nix b/nixos/tests/nixos-test-driver/timeout.nix
new file mode 100644
index 0000000000000..29bd85d2498ea
--- /dev/null
+++ b/nixos/tests/nixos-test-driver/timeout.nix
@@ -0,0 +1,15 @@
+{
+  name = "Test that sleep of 6 seconds fails a timeout of 5 seconds";
+  globalTimeout = 5;
+
+  nodes = {
+    machine = ({ pkgs, ... }: {
+    });
+  };
+
+  testScript = ''
+    start_all()
+    machine.wait_for_unit("multi-user.target")
+    machine.succeed("sleep 6")
+  '';
+}