mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 07:01:54 +00:00
nixos tests: add logrotate test
make sure the service is enabled by default and works.
This commit is contained in:
parent
c132bfaa19
commit
a05f1c9f93
@ -268,6 +268,7 @@ in
|
||||
litestream = handleTest ./litestream.nix {};
|
||||
locate = handleTest ./locate.nix {};
|
||||
login = handleTest ./login.nix {};
|
||||
logrotate = handleTest ./logrotate.nix {};
|
||||
loki = handleTest ./loki.nix {};
|
||||
lxd = handleTest ./lxd.nix {};
|
||||
lxd-image = handleTest ./lxd-image.nix {};
|
||||
|
35
nixos/tests/logrotate.nix
Normal file
35
nixos/tests/logrotate.nix
Normal file
@ -0,0 +1,35 @@
|
||||
# Test logrotate service works and is enabled by default
|
||||
|
||||
import ./make-test-python.nix ({ pkgs, ...} : rec {
|
||||
name = "logrotate";
|
||||
meta = with pkgs.lib.maintainers; {
|
||||
maintainers = [ martinetd ];
|
||||
};
|
||||
|
||||
# default machine
|
||||
machine = { ... }: {
|
||||
};
|
||||
|
||||
testScript =
|
||||
''
|
||||
with subtest("whether logrotate works"):
|
||||
machine.succeed(
|
||||
# we must rotate once first to create logrotate stamp
|
||||
"systemctl start --wait logrotate.service",
|
||||
|
||||
# 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",
|
||||
|
||||
# check rotate worked
|
||||
"[ -e /var/log/wtmp.1 ]",
|
||||
)
|
||||
'';
|
||||
})
|
@ -1,6 +1,7 @@
|
||||
{ lib, stdenv, fetchFromGitHub, gzip, popt, autoreconfHook
|
||||
, mailutils ? null
|
||||
, aclSupport ? true, acl
|
||||
, nixosTests
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
@ -25,6 +26,10 @@ stdenv.mkDerivation rec {
|
||||
nativeBuildInputs = [ autoreconfHook ];
|
||||
buildInputs = [ popt ] ++ lib.optionals aclSupport [ acl ];
|
||||
|
||||
passthru.tests = {
|
||||
nixos-logrotate = nixosTests.logrotate;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/logrotate/logrotate";
|
||||
description = "Rotates and compresses system logs";
|
||||
|
Loading…
Reference in New Issue
Block a user