diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2022-02-11 17:49:52 +0900 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2022-02-13 07:29:40 +0900 |
commit | a05f1c9f9357d3c3c39b99a5aa020399ee28bb99 (patch) | |
tree | b88e064c48dd4f50a0cf7c3a7b1fc65a857e815e /nixos/tests | |
parent | c132bfaa19ea08cce7c261ab4f0bda42bfc76b48 (diff) | |
download | nixpkgs-a05f1c9f9357d3c3c39b99a5aa020399ee28bb99.tar nixpkgs-a05f1c9f9357d3c3c39b99a5aa020399ee28bb99.tar.gz nixpkgs-a05f1c9f9357d3c3c39b99a5aa020399ee28bb99.tar.bz2 nixpkgs-a05f1c9f9357d3c3c39b99a5aa020399ee28bb99.tar.lz nixpkgs-a05f1c9f9357d3c3c39b99a5aa020399ee28bb99.tar.xz nixpkgs-a05f1c9f9357d3c3c39b99a5aa020399ee28bb99.tar.zst nixpkgs-a05f1c9f9357d3c3c39b99a5aa020399ee28bb99.zip |
nixos tests: add logrotate test
make sure the service is enabled by default and works.
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/logrotate.nix | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 3fd4945ed35..9238e831c50 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -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 {}; diff --git a/nixos/tests/logrotate.nix b/nixos/tests/logrotate.nix new file mode 100644 index 00000000000..0f6b59f071d --- /dev/null +++ b/nixos/tests/logrotate.nix @@ -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 ]", + ) + ''; +}) |