Skip to content

Commit

Permalink
Extend test
Browse files Browse the repository at this point in the history
  • Loading branch information
SFrijters committed Dec 16, 2024
1 parent 86fd02b commit c80aa00
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@
postfix.enable = true;
logwatch = {
enable = true;
range = "since 24 hours ago for those hours";
removeScripts = [ "zz-network" ];
journalCtlEntries = [
{
name = "postfix";
output = "short";
}
];
};
};

Expand All @@ -63,11 +70,13 @@
import time
start_all()
server.wait_for_unit("default.target")
# Force restart of logwatch so it sends a mail
server.systemctl("restart logwatch")
# VMs on CI runners can be kind of slow, delay here
time.sleep(3)
# Get all mails for root and check if the expected subject is there
# Get all mails for root and check if the expected data is there
mail = server.succeed("mail -p")
print(mail)
if "Subject: Logwatch for server" not in mail:
Expand All @@ -84,6 +93,21 @@
} in output of 'mail -p'")
if "Network statistics" in mail:
raise Exception("Network statistics should have been removed by removeScripts")
# Clean mailbox
server.succeed("echo 'd *' | mail -N")
# Force restart of logwatch to re-analyze to logs
# It should now include a delivered mail in the Postfix output
server.systemctl("restart logwatch")
# VMs on CI runners can be kind of slow, delay here
time.sleep(3)
# Get all mails for root and check if the expected data is there
mail = server.succeed("mail -p")
print(mail)
if "1 Delivered" not in mail:
raise Exception("Missing test '1 Delivered' in output of 'mail -p'")
'';
};
});
Expand Down

0 comments on commit c80aa00

Please sign in to comment.