[check_postgres] [commit] Tests for settings_checksum

check_postgres at bucardo.org check_postgres at bucardo.org
Fri Apr 24 16:20:01 UTC 2009


Committed by Jeff Boes <jeff at endpoint.com>

Tests for settings_checksum

---
 t/02_settings_checksum.t |   56 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/t/02_settings_checksum.t b/t/02_settings_checksum.t
new file mode 100644
index 0000000..a472bcb
--- /dev/null
+++ b/t/02_settings_checksum.t
@@ -0,0 +1,56 @@
+#!perl
+
+## Test the "settings_checksum" action
+
+use strict;
+use warnings;
+use Data::Dumper;
+use DBI;
+use Test::More tests => 8;
+use lib 't','.';
+use CP_Testing;
+
+use vars qw/$dbh $result $t $host $dbname $testtbl $testtrig_prefix/;
+
+$testtbl = 'test_settings_checksum';
+$testtrig_prefix = 'test_settings_checksum_';
+
+my $cp = CP_Testing->new( {default_action => 'settings_checksum'} );
+
+$dbh = $cp->test_database_handle();
+$dbname = $cp->get_dbname;
+$host = $cp->get_host();
+my $label = 'POSTGRES_SETTINGS_CHECKSUM';
+
+my $S = q{Action 'settings_checksum'};
+
+$t = qq{$S self-identifies correctly};
+$result = $cp->run('--critical 0');
+like ($result, qr{^$label}, $t);
+
+$t = qq{$S identifies database};
+like ($result, qr{DB "$dbname"}, $t);
+
+$t = qq{$S identifies host};
+like ($result, qr{host:$host}, $t);
+
+my $true_checksum;
+$true_checksum = $1 if $result =~ /checksum: ([0-9a-f]{32})/;
+
+$t = qq{$S reports missing flag};
+is ($cp->run(), qq{ERROR: Must provide a 'warning' or 'critical' option\n}, $t);
+
+$t = qq{$S rejects -w and -c together};
+is ($cp->run('-w abcdabcdabcdabcdabcdabcdabcdabcd -c abcdabcdabcdabcdabcdabcdabcdabcd'),
+    qq{ERROR: Can only provide 'warning' OR 'critical' option\n}, $t);
+
+$t = qq{$S notes mismatched checksum (warning)};
+like ($cp->run('-w abcdabcdabcdabcdabcdabcdabcdabcd'),
+      qr{$label WARNING: .* checksum:}, $t);
+
+$t = qq{$S notes mismatched checksum (critical)};
+like ($cp->run('-c abcdabcdabcdabcdabcdabcdabcdabcd'),
+      qr{$label CRITICAL: .* checksum:}, $t);
+
+$t = qq{$S accepts matching checksum};
+like ($cp->run("-w $true_checksum"), qr/OK.*\Qchecksum: $true_checksum\E/, $t);
-- 
1.6.0.5



More information about the Check_postgres mailing list