Skip to content

Commit

Permalink
nixos/switch-to-configuration: fix dbus implementation used for test
Browse files Browse the repository at this point in the history
Makes the switch-test work with both dbus server implementations.
  • Loading branch information
jmbaur committed Apr 30, 2024
1 parent 3e67815 commit 3cdbad2
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions nixos/tests/switch-test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ in {
# Returns a comma separated representation of the given list in sorted
# order, that matches the output format of switch-to-configuration.pl
sortedUnits = xs: lib.concatStringsSep ", " (builtins.sort builtins.lessThan xs);

dbusService = {
"dbus" = "dbus.service";
"broker" = "dbus-broker.service";
}.${nodes.machine.services.dbus.implementation};
in /* python */ ''
def switch_to_specialisation(system, name, action="test", fail=False):
if name == "":
Expand Down Expand Up @@ -691,9 +696,9 @@ in {
with subtest("continuing from an aborted switch"):
# An aborted switch will write into a file what it tried to start
# and a second switch should continue from this
machine.succeed("echo dbus-broker.service > /run/nixos/start-list")
machine.succeed("echo ${dbusService} > /run/nixos/start-list")
out = switch_to_specialisation("${machine}", "modifiedSystemConf")
assert_contains(out, "starting the following units: dbus-broker.service\n")
assert_contains(out, "starting the following units: ${dbusService}\n")
with subtest("fstab mounts"):
switch_to_specialisation("${machine}", "")
Expand Down Expand Up @@ -732,15 +737,15 @@ in {
out = switch_to_specialisation("${machine}", "")
assert_contains(out, "stopping the following units: test.mount\n")
assert_lacks(out, "NOT restarting the following changed units:")
assert_contains(out, "reloading the following units: dbus-broker.service\n")
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:")
# change something about the / mount
out = switch_to_specialisation("${machine}", "storeMountModified")
assert_lacks(out, "stopping the following units:")
assert_contains(out, "NOT restarting the following changed units: -.mount")
assert_contains(out, "reloading the following units: dbus-broker.service\n")
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:")
Expand All @@ -751,7 +756,7 @@ in {
out = switch_to_specialisation("${machine}", "swap")
assert_lacks(out, "stopping the following units:")
assert_lacks(out, "NOT restarting the following changed units:")
assert_contains(out, "reloading the following units: dbus-broker.service\n")
assert_contains(out, "reloading the following units: ${dbusService}\n")
assert_lacks(out, "\nrestarting the following units:")
assert_lacks(out, "\nstarting the following units:")
assert_contains(out, "the following new units were started: swapfile.swap")
Expand All @@ -760,7 +765,7 @@ in {
assert_contains(out, "stopping swap device: /swapfile")
assert_lacks(out, "stopping the following units:")
assert_lacks(out, "NOT restarting the following changed units:")
assert_contains(out, "reloading the following units: dbus-broker.service\n")
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:")
Expand All @@ -781,7 +786,7 @@ in {
assert_lacks(out, "installing dummy bootloader") # test does not install a bootloader
assert_lacks(out, "stopping the following units:")
assert_lacks(out, "NOT restarting the following changed units:")
assert_contains(out, "reloading the following units: dbus-broker.service\n") # huh
assert_contains(out, "reloading the following units: ${dbusService}\n") # huh
assert_lacks(out, "\nrestarting the following units:")
assert_lacks(out, "\nstarting the following units:")
assert_contains(out, "the following new units were started: test.service\n")
Expand Down Expand Up @@ -858,7 +863,7 @@ in {
assert_lacks(out, "installing dummy bootloader") # test does not install a bootloader
assert_lacks(out, "stopping the following units:")
assert_lacks(out, "NOT restarting the following changed units:")
assert_contains(out, "reloading the following units: dbus-broker.service\n") # huh
assert_contains(out, "reloading the following units: ${dbusService}\n") # huh
assert_lacks(out, "\nrestarting the following units:")
assert_lacks(out, "\nstarting the following units:")
assert_contains(out, "the following new units were started: test.service\n")
Expand Down

0 comments on commit 3cdbad2

Please sign in to comment.