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.
This commit is contained in:
Dominique Martinet 2022-02-26 16:04:44 +09:00
parent 33984cd89c
commit 4d12b79cd7
2 changed files with 9 additions and 9 deletions

View File

@ -167,7 +167,6 @@ in
systemd.services.logrotate = { systemd.services.logrotate = {
description = "Logrotate Service"; description = "Logrotate Service";
wantedBy = [ "multi-user.target" ];
startAt = "hourly"; startAt = "hourly";
serviceConfig = { serviceConfig = {

View File

@ -15,19 +15,20 @@ import ./make-test-python.nix ({ pkgs, ...} : rec {
with subtest("whether logrotate works"): with subtest("whether logrotate works"):
machine.succeed( machine.succeed(
# we must rotate once first to create logrotate stamp # 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. # wtmp is present in default config.
"rm -f /var/log/wtmp*", "rm -f /var/log/wtmp*",
"echo test > /var/log/wtmp", "echo test > /var/log/wtmp",
# move into the future and rotate # move into the future and check rotation.
"date -s 'now + 1 month + 1 day'", "date -s 'now + 1 month + 1 day'")
# systemd will run logrotate from logrotate.timer automatically machine.wait_for_console_text('logrotate.service: Deactivated successfully')
# on date change, but if we want to wait for it to terminate machine.succeed(
# it's easier to run again...
"systemctl start --wait logrotate.service",
# check rotate worked # check rotate worked
"[ -e /var/log/wtmp.1 ]", "[ -e /var/log/wtmp.1 ]",
) )