From 1566668de7d64de57f8cc2cfd805dcdfbcbae92d Mon Sep 17 00:00:00 2001 From: Jeff Boes Date: Fri, 24 Apr 2009 17:10:07 -0400 Subject: [PATCH] Tests for autovac_freeze. --- t/02_autovac_freeze.t | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 t/02_autovac_freeze.t diff --git a/t/02_autovac_freeze.t b/t/02_autovac_freeze.t new file mode 100644 index 000000000..efe20767d --- /dev/null +++ b/t/02_autovac_freeze.t @@ -0,0 +1,48 @@ +#!perl + +## Test the "autovac_freeze" 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/; + +my $cp = CP_Testing->new( {default_action => 'autovac_freeze'} ); + +$dbh = $cp->test_database_handle(); +$dbh->{AutoCommit} = 1; +$dbname = $cp->get_dbname; +$host = $cp->get_host(); +my $label = 'POSTGRES_AUTOVAC_FREEZE'; + +my $S = q{Action 'autovac_freeze'}; + +$t = qq{$S self-identifies correctly}; +$result = $cp->run(qq{-w 0%}); +like ($result, qr{^$label}, $t); + +$t = qq{$S identifies host}; +like ($result, qr{host:$host}, $t); + +$t=qq{$S fails when called with an invalid option}; +like ($cp->run('foobar=12'), qr{^\s*Usage:}, $t); + +$t=qq{$S fails when called with an invalid --warning option}; +like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t); + +$t=qq{$S fails when called with an invalid --critical option}; +like ($cp->run('--critical=50'), qr{ERROR:.+must be a percentage}, $t); + +$t=qq{$S flags when database is over freeze threshold}; +like ($cp->run('-w 0%'), qr{$label WARNING:.*ardala=\d+%.*?beedeebeedee=\d+%.*?postgres=\d+%.*?template1=\d+%}, $t); + +$t=qq{$S flags when database is under freeze threshold}; +like ($cp->run('-w 99%'), qr{$label OK:.*ardala=\d+%.*?beedeebeedee=\d+%.*?postgres=\d+%.*?template1=\d+%}, $t); + +$t=qq{$S produces MRTG output}; +like ($cp->run('--output=mrtg -w 99%'), qr{0\n\d+\n\nardala \| beedeebeedee \| postgres \| template1\n}, $t); -- 2.39.5