@ -1,26 +1,33 @@
# Test logrotate service works and is enabled by default
import ./make-test-python.nix ( { pkgs , . . . } : rec {
import ./make-test-python.nix ( { pkgs , . . . }: rec {
name = " l o g r o t a t e " ;
meta = with pkgs . lib . maintainers ; {
maintainers = [ martinetd ] ;
} ;
# default machine
nodes . machine = { . . . }: {
nodes = {
defaultMachine = { . . . }: { } ;
machine = { config , . . . }: {
services . logrotate . paths = {
# using mail somewhere should add --mail to logrotate invokation
sendmail = {
extraConfig = " m a i l u s e r @ d o m a i n . t l d " ;
} ;
} ;
} ;
} ;
testScript =
''
with subtest ( " w h e t h e r l o g r o t a t e w o r k s " ) :
machine . succeed (
# we must rotate once first to create logrotate stamp
" s y s t e m c t l s t a r t l o g r o t a t e . s e r v i c e " )
# we must rotate once first to create logrotate stamp
defaultMachine . succeed ( " s y s t e m c t l s t a r t l o g r o t a t e . s e r v i c e " )
# we need to wait for console text once here to
# clear console buffer up to this point for next wait
m achine. wait_for_console_text ( ' logrotate . service : Deactivated successfully' )
defaultM achine. wait_for_console_text ( ' logrotate . service : Deactivated successfully' )
m achine. succeed (
defaultM achine. succeed (
# wtmp is present in default config.
" r m - f / v a r / l o g / w t m p * " ,
# we need to give it at least 1MB
@ -28,10 +35,14 @@ import ./make-test-python.nix ({ pkgs, ...} : rec {
# move into the future and check rotation.
" d a t e - s ' n o w + 1 m o n t h + 1 d a y ' " )
m achine. wait_for_console_text ( ' logrotate . service : Deactivated successfully' )
m achine. succeed (
defaultM achine. wait_for_console_text ( ' logrotate . service : Deactivated successfully' )
defaultM achine. succeed (
# check rotate worked
" [ - e / v a r / l o g / w t m p . 1 ] " ,
)
with subtest ( " d e f a u l t c o n f i g d o e s n o t h a v e m a i l " ) :
defaultMachine . fail ( " s y s t e m c t l c a t l o g r o t a t e . s e r v i c e | g r e p - - - - m a i l " )
with subtest ( " u s i n g m a i l s a d d s m a i l o p t i o n " ) :
machine . succeed ( " s y s t e m c t l c a t l o g r o t a t e . s e r v i c e | g r e p - - - - m a i l " )
'' ;
} )