at 23.05-pre 2.1 kB view raw
1# Regression test for systemd-timesync having moved the state directory without 2# upstream providing a migration path. https://github.com/systemd/systemd/issues/12131 3 4import ./make-test-python.nix (let 5 common = { lib, ... }: { 6 # override the `false` value from the qemu-vm base profile 7 services.timesyncd.enable = lib.mkForce true; 8 }; 9 mkVM = conf: { imports = [ conf common ]; }; 10in { 11 name = "systemd-timesyncd"; 12 nodes = { 13 current = mkVM {}; 14 pre1909 = mkVM ({lib, ... }: with lib; { 15 # create the path that should be migrated by our activation script when 16 # upgrading to a newer nixos version 17 system.stateVersion = "19.03"; 18 system.activationScripts.simulate-old-timesync-state-dir = mkBefore '' 19 rm -f /var/lib/systemd/timesync 20 mkdir -p /var/lib/systemd /var/lib/private/systemd/timesync 21 ln -s /var/lib/private/systemd/timesync /var/lib/systemd/timesync 22 chown systemd-timesync: /var/lib/private/systemd/timesync 23 ''; 24 }); 25 }; 26 27 testScript = '' 28 start_all() 29 current.succeed("systemctl status systemd-timesyncd.service") 30 # on a new install with a recent systemd there should not be any 31 # leftovers from the dynamic user mess 32 current.succeed("test -e /var/lib/systemd/timesync") 33 current.succeed("test ! -L /var/lib/systemd/timesync") 34 35 # timesyncd should be running on the upgrading system since we fixed the 36 # file bits in the activation script 37 pre1909.succeed("systemctl status systemd-timesyncd.service") 38 39 # the path should be gone after the migration 40 pre1909.succeed("test ! -e /var/lib/private/systemd/timesync") 41 42 # and the new path should no longer be a symlink 43 pre1909.succeed("test -e /var/lib/systemd/timesync") 44 pre1909.succeed("test ! -L /var/lib/systemd/timesync") 45 46 # after a restart things should still work and not fail in the activation 47 # scripts and cause the boot to fail.. 48 pre1909.shutdown() 49 pre1909.start() 50 pre1909.succeed("systemctl status systemd-timesyncd.service") 51 ''; 52})