From f92ec1bc93990197895f4ce4bcf29354a738f830 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Mon, 4 Nov 2024 00:51:58 -0500 Subject: [PATCH] nixos/tests/switchTest: Add test for dbus reloading --- nixos/tests/switch-test.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix index 98b145c58e81..a55155579b4b 100644 --- a/nixos/tests/switch-test.nix +++ b/nixos/tests/switch-test.nix @@ -593,6 +593,19 @@ in { imports = [ slice.configuration ]; systemd.slices.testslice.sliceConfig.MemoryMax = lib.mkForce null; }; + + dbusReload.configuration = { config, ... }: let + dbusService = { + "dbus" = "dbus"; + "broker" = "dbus-broker"; + }.${config.services.dbus.implementation}; + in { + # We want to make sure that stc catches this as a reload, + # not a restart. + systemd.services.${dbusService}.restartTriggers = [ + (pkgs.writeText "dbus-reload-dummy" "dbus reload dummy") + ]; + }; }; }; @@ -1422,5 +1435,15 @@ in { assert_lacks(out, "the following new units were started:") machine.succeed("systemctl start testservice.service") machine.succeed("echo 1 > /proc/sys/vm/panic_on_oom") # disallow OOMing + + with subtest("dbus reloads"): + out = switch_to_specialisation("${machine}", "") + out = switch_to_specialisation("${machine}", "dbusReload") + assert_lacks(out, "stopping the following units:") + assert_lacks(out, "NOT restarting the following changed units:") + assert_contains(out, "reloading the following units: ${dbusService}\n") + assert_lacks(out, "\nrestarting the following units:") + assert_lacks(out, "\nstarting the following units:") + assert_lacks(out, "the following new units were started:") ''; })