From 777b469485f8091f114fcfbe1d9255026051ad0e Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Mon, 28 Nov 2022 14:44:19 +0100 Subject: [PATCH] bkctld check-canary: add tests --- server/test/checks.bats | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/test/checks.bats b/server/test/checks.bats index 48c74ea..4dba35e 100644 --- a/server/test/checks.bats +++ b/server/test/checks.bats @@ -252,3 +252,25 @@ OUT assert_failure } # TODO: write many more tests for bkctld-check-incs + +@test "Check-canary fails if a canary file doesn't exist" { + run /usr/lib/bkctld/bkctld-check-canary "${JAILNAME}" + assert_equal "$status" "2" + assert_line "CRITICAL - ${JAILNAME} - missing /zzz_evobackup_canary file" +} + +@test "Check-canary fails if a canary is missing today's entries" { + today="$(date +%Y-%m-%d)" + touch "${JAILPATH}/var/backup/zzz_evobackup_canary" + + run /usr/lib/bkctld/bkctld-check-canary "${JAILNAME}" + assert_equal "$status" "2" + assert_line "CRITICAL - ${JAILNAME} - No entry for ${today} in /zzz_evobackup_canary file" +} + +@test "Check-canary succeeds if a canary has today's entries" { + echo "$(date "+%FT%T%z") bats-test" >> "${JAILPATH}/var/backup/zzz_evobackup_canary" + + run /usr/lib/bkctld/bkctld-check-canary "${JAILNAME}" + assert_success +} \ No newline at end of file