diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 9852b5f5b8b9..afcd460418d4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -434,7 +434,7 @@ in drbd-driver = runTest ./drbd-driver.nix; dublin-traceroute = runTest ./dublin-traceroute.nix; dwl = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./dwl.nix; - earlyoom = handleTestOn [ "x86_64-linux" ] ./earlyoom.nix { }; + earlyoom = runTestOn [ "x86_64-linux" ] ./earlyoom.nix; early-mount-options = handleTest ./early-mount-options.nix { }; ec2-config = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).boot-ec2-config or { }; ec2-nixops = (handleTestOn [ "x86_64-linux" ] ./ec2.nix { }).boot-ec2-nixops or { }; diff --git a/nixos/tests/earlyoom.nix b/nixos/tests/earlyoom.nix index 874634bb2229..35415bed87a3 100644 --- a/nixos/tests/earlyoom.nix +++ b/nixos/tests/earlyoom.nix @@ -1,42 +1,38 @@ -import ./make-test-python.nix ( - { lib, ... }: - { - name = "earlyoom"; - meta = { - maintainers = with lib.maintainers; [ - ncfavier - oxalica - ]; - }; +{ lib, ... }: +{ + name = "earlyoom"; + meta.maintainers = with lib.maintainers; [ + ncfavier + oxalica + ]; - nodes.machine = - { pkgs, ... }: - { - # Limit VM resource usage. - virtualisation.memorySize = 1024; + nodes.machine = + { pkgs, ... }: + { + # Limit VM resource usage. + virtualisation.memorySize = 1024; - services.earlyoom = { - enable = true; - # Use SIGKILL, or `tail` will catch SIGTERM and exit successfully. - freeMemKillThreshold = 90; - }; - - systemd.services.testbloat = { - description = "Create a lot of memory pressure"; - serviceConfig = { - ExecStart = "${pkgs.coreutils}/bin/tail /dev/zero"; - }; - }; + services.earlyoom = { + enable = true; + # Use SIGKILL, or `tail` will catch SIGTERM and exit successfully. + freeMemKillThreshold = 90; }; - testScript = '' - machine.wait_for_unit("earlyoom.service") + systemd.services.testbloat = { + description = "Create a lot of memory pressure"; + serviceConfig = { + ExecStart = "${pkgs.coreutils}/bin/tail /dev/zero"; + }; + }; + }; - with subtest("earlyoom should kill the bad service"): - machine.fail("systemctl start --wait testbloat.service") - assert machine.get_unit_info("testbloat.service")["Result"] == "signal" - output = machine.succeed('journalctl -u earlyoom.service -b0') - assert 'low memory! at or below SIGKILL limits' in output - ''; - } -) + testScript = '' + machine.wait_for_unit("earlyoom.service") + + with subtest("earlyoom should kill the bad service"): + machine.fail("systemctl start --wait testbloat.service") + assert machine.get_unit_info("testbloat.service")["Result"] == "signal" + output = machine.succeed('journalctl -u earlyoom.service -b0') + assert 'low memory! at or below SIGKILL limits' in output + ''; +}