From cfb78b424ad3632599935cdce285c1b1a7a24da6 Mon Sep 17 00:00:00 2001 From: Christoph Moench-Tegeder Date: Wed, 29 Sep 2021 23:11:49 +0200 Subject: [PATCH] align check_wal_files() code with it's test case Test 02_wal_files.t may fail against a newly created (by the framework in CP_Testing.pm) database (PostgreSQL 13) with : Failed test 'Action 'wal_files' works as expected for warnings' : at t/02_wal_files.t line 44. : 'POSTGRES_WAL_FILES OK: DB "postgres" (host:/tmp/cptesting_socket) WAL files found: 1 | time=0.01s files=1;1 : ' : doesn't match '(?^:^POSTGRES_WAL_FILES WARNING)' as there is exactly one WAL file and the test expects the check to raise warning/critical alerts at one WAL file - just as the documentation of the alert levels says "the threshold at wich a warning/critical alert is fired", but the code in check_wal_files() checks if the number of files is _greater_ than the alerting threshold. Admitted that this is a corner case, but it is annoying af when running the tests. Fix by converting the greater '>' into 'greater-or-equal' '>=' checks. --- check_postgres.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index be5ccdb..31f3698 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -9042,10 +9042,10 @@ sub check_wal_files { : msg('wal-numfound', $numfiles); $db->{perf} .= sprintf '%s=%s;%s;%s', perfname(msg('files')), $numfiles, $warning, $critical; - if (length $critical and $numfiles > $critical) { + if (length $critical and $numfiles >= $critical) { add_critical $msg; } - elsif (length $warning and $numfiles > $warning) { + elsif (length $warning and $numfiles >= $warning) { add_warning $msg; } else {