summary refs log tree commit diff
path: root/nixos/tests/logrotate.nix
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2022-02-26 16:04:44 +0900
committerDominique Martinet <asmadeus@codewreck.org>2022-02-26 19:13:12 +0900
commit4d12b79cd7edfbe01216171dd6ef0e4c64851b0a (patch)
tree6a887d87cc6ce067c910c2bf82b81eafdd4c8ee2 /nixos/tests/logrotate.nix
parent33984cd89ca94954353be396631bcb6a9190c0d2 (diff)
downloadnixpkgs-4d12b79cd7edfbe01216171dd6ef0e4c64851b0a.tar
nixpkgs-4d12b79cd7edfbe01216171dd6ef0e4c64851b0a.tar.gz
nixpkgs-4d12b79cd7edfbe01216171dd6ef0e4c64851b0a.tar.bz2
nixpkgs-4d12b79cd7edfbe01216171dd6ef0e4c64851b0a.tar.lz
nixpkgs-4d12b79cd7edfbe01216171dd6ef0e4c64851b0a.tar.xz
nixpkgs-4d12b79cd7edfbe01216171dd6ef0e4c64851b0a.tar.zst
nixpkgs-4d12b79cd7edfbe01216171dd6ef0e4c64851b0a.zip
logrotate: do not enable logrotate.service itself
logrotate.timer is enough for rotating logs. Enabling logrotate.service would
make the service start on every configuration switch, leading to tests failure when
logrotate is enabled.

Also update test to make sure the timer is active and runs the service
on date change.
Diffstat (limited to 'nixos/tests/logrotate.nix')
-rw-r--r--nixos/tests/logrotate.nix17
1 files changed, 9 insertions, 8 deletions
diff --git a/nixos/tests/logrotate.nix b/nixos/tests/logrotate.nix
index 0f6b59f071d..0dee5d4502d 100644
--- a/nixos/tests/logrotate.nix
+++ b/nixos/tests/logrotate.nix
@@ -15,19 +15,20 @@ import ./make-test-python.nix ({ pkgs, ...} : rec {
       with subtest("whether logrotate works"):
           machine.succeed(
               # we must rotate once first to create logrotate stamp
-              "systemctl start --wait logrotate.service",
+              "systemctl start logrotate.service")
+          # we need to wait for console text once here to
+          # clear console buffer up to this point for next wait
+          machine.wait_for_console_text('logrotate.service: Deactivated successfully')
 
+          machine.succeed(
               # wtmp is present in default config.
               "rm -f /var/log/wtmp*",
               "echo test > /var/log/wtmp",
 
-              # move into the future and rotate
-              "date -s 'now + 1 month + 1 day'",
-              # systemd will run logrotate from logrotate.timer automatically
-              # on date change, but if we want to wait for it to terminate
-              # it's easier to run again...
-              "systemctl start --wait logrotate.service",
-
+              # move into the future and check rotation.
+              "date -s 'now + 1 month + 1 day'")
+          machine.wait_for_console_text('logrotate.service: Deactivated successfully')
+          machine.succeed(
               # check rotate worked
               "[ -e /var/log/wtmp.1 ]",
           )