summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Lelarge2011-09-03 10:21:53 +0000
committerGuillaume Lelarge2011-09-03 17:55:31 +0000
commit9012739cdb908ea20506920124331ea7d08f4dca (patch)
tree139eed364f1ad28568cd25bcfb96e20c020f81cf
parenta295085d0482a6160c19b732a48bc8b2f41b40f8 (diff)
Fix some "make test" issues
* backends test issue Critical and warning values were wrong for the negative number check. And the output message for the --include check was wrong too. * check_replicate_row issue The UPDATE must be executed on the first server only. * fsm_pages and fsm_relations test issue The version test (ie max_fsm_* not available on 8.4 and later releases) must be done earlier. * doc test issue check_standby_mode rename to make_sure_standby_mode because all check_* functions are expected to have documentation, but check_standby_mode is an internal function. * another doc test issue pgbouncer_checksum documentation wasn't at the right location. * drop_schema_if_exists issue There was an unexpected return in the middle of the function, and so the schema was never dropped.
-rwxr-xr-xcheck_postgres.pl62
-rw-r--r--t/02_backends.t10
-rw-r--r--t/02_fsm_pages.t26
-rw-r--r--t/02_fsm_relations.t24
-rw-r--r--t/CP_Testing.pm1
5 files changed, 61 insertions, 62 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index a3418489e..7d9f2b0d8 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1243,7 +1243,7 @@ if ($opt{showtime}) {
## Check the current database mode
our $STANDBY = 0;
-check_standby_mode() if $opt{'assume-standby-mode'};
+make_sure_standby_mode() if $opt{'assume-standby-mode'};
## We don't (usually) want to die, but want a graceful Nagios-like exit instead
sub ndie {
@@ -1511,7 +1511,7 @@ sub do_mrtg_stats {
do_mrtg({one => $one, two => $two, msg => $msg});
}
-sub check_standby_mode {
+sub make_sure_standby_mode {
## Checks if database in standby mode
## Requires $ENV{PGDATA} or --datadir
@@ -1570,7 +1570,7 @@ sub check_standby_mode {
return;
-} ## end of check_standby_mode
+} ## end of make_sure_standby_mode
sub finishup {
@@ -2461,7 +2461,7 @@ sub run_command {
sub setup_target_databases {
## Build a list of all databases to connect to.
- ## Returns a list of all such databases with conenction information:
+ ## Returns a list of all such databases with connection information:
## -- dbuser, --dbpass, --dbservice, --port, --dbname, --host
##
## Items are determined by host, port, and db arguments
@@ -2484,7 +2484,7 @@ sub setup_target_databases {
## --host=a,b --host=x --port=5432,5433 --dbuser=alice --dbuser=bob --db=baz
## Connects three times: a-5432-alice-baz b-5433-alice-baz x-5433-bob-baz
- ## Returns a list of targets as as hashref
+ ## Returns a list of targets as a hashref
my $arg = shift || {};
@@ -5897,7 +5897,7 @@ sub check_replicate_row {
ndie msg('rep-wrongvals', $value1, $val1, $val2);
}
- $info1 = run_command($update, { failok => 1 } );
+ $info1 = run_command($update, { dbnumber => 1, failok => 1 } );
## Make sure the update worked
if (! defined $info1->{db}[0]) {
@@ -8628,31 +8628,6 @@ tool that can send mail when interesting events appear in your Postgres logs.
See: http://bucardo.org/wiki/Tail_n_mail for more information).
See also the information on the C<--get_method> option.
-=head2 B<pgbouncer_checksum>
-
-(C<symlink: check_postgres_pgbouncer_checksum>) Checks that all the
-pgBouncer settings are the same as last time you checked.
-This is done by generating a checksum of a sorted list of setting names and
-their values. Note that you shouldn't specify the database name, it will
-automatically default to pgbouncer. Either the I<--warning> or the I<--critical> option
-should be given, but not both. The value of each one is the checksum, a
-32-character hexadecimal value. You can run with the special C<--critical=0> option
-to find out an existing checksum.
-
-This action requires the Digest::MD5 module.
-
-Example 1: Find the initial checksum for pgbouncer configuration on port 6432 using the default user (usually postgres)
-
- check_postgres_pgbouncer_checksum --port=6432 --critical=0
-
-Example 2: Make sure no settings have changed and warn if so, using the checksum from above.
-
- check_postgres_pgbouncer_checksum --port=6432 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
-
-For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A
-checksum must be provided as the C<--mrtg> argument. The fourth line always gives the
-current checksum.
-
=head2 B<pgb_pool_cl_active>
=head2 B<pgb_pool_cl_waiting>
@@ -8727,6 +8702,31 @@ the fourth line gives the name of the database, plus the current
max_client_conn. If more than one database has been queried, the one with the
highest number of connections is output.
+=head2 B<pgbouncer_checksum>
+
+(C<symlink: check_postgres_pgbouncer_checksum>) Checks that all the
+pgBouncer settings are the same as last time you checked.
+This is done by generating a checksum of a sorted list of setting names and
+their values. Note that you shouldn't specify the database name, it will
+automatically default to pgbouncer. Either the I<--warning> or the I<--critical> option
+should be given, but not both. The value of each one is the checksum, a
+32-character hexadecimal value. You can run with the special C<--critical=0> option
+to find out an existing checksum.
+
+This action requires the Digest::MD5 module.
+
+Example 1: Find the initial checksum for pgbouncer configuration on port 6432 using the default user (usually postgres)
+
+ check_postgres_pgbouncer_checksum --port=6432 --critical=0
+
+Example 2: Make sure no settings have changed and warn if so, using the checksum from above.
+
+ check_postgres_pgbouncer_checksum --port=6432 --warning=cd2f3b5e129dc2b4f5c0f6d8d2e64231
+
+For MRTG output, returns a 1 or 0 indicating success of failure of the checksum to match. A
+checksum must be provided as the C<--mrtg> argument. The fourth line always gives the
+current checksum.
+
=head2 B<prepared_txns>
(C<symlink: check_postgres_prepared_txns>) Check on the age of any existing prepared transactions.
diff --git a/t/02_backends.t b/t/02_backends.t
index 255f56310..4dd03b67f 100644
--- a/t/02_backends.t
+++ b/t/02_backends.t
@@ -123,10 +123,10 @@ like ($cp->run("-c ${num}0%"), qr{^$label CRITICAL}, $t);
like ($cp->run('-c 40%'), qr{^$label OK}, $t);
$t=qq{$S works with critical option as a negative number};
-like ($cp->run('-c -6'), qr{^$label CRITICAL}, $t);
-like ($cp->run('-c -7'), qr{^$label CRITICAL}, $t);
-$num = $goodver ? 8 : 9;
-like ($cp->run("-c -$num"), qr{^$label OK}, $t);
+like ($cp->run('-c -5'), qr{^$label OK}, $t);
+like ($cp->run('-c -6'), qr{^$label OK}, $t);
+$num = $goodver ? 7 : 8;
+like ($cp->run("-c -$num"), qr{^$label CRITICAL}, $t);
$t=qq{$S works when no items caught by pg_stat_activity};
@@ -173,7 +173,7 @@ SKIP: {
like ($cp->run('--include=postgres --exclude=postgres'), qr{^$label OK: .+3 of 10}, $t);
$t=qq{$S returned correct performance data with include};
- like ($cp->run('--include=postgres'), qr{ \| time=\d\.\d\ds ardala=0;9;9;0;10 beedeebeedee=0;9;9;0;10 postgres=3;9;9;0;10}, $t);
+ like ($cp->run('--include=postgres'), qr{ \| time=\d\.\d\ds postgres=3;9;9;0;10}, $t);
}
my %dbh;
diff --git a/t/02_fsm_pages.t b/t/02_fsm_pages.t
index bbe5a97e5..ce3b71618 100644
--- a/t/02_fsm_pages.t
+++ b/t/02_fsm_pages.t
@@ -28,6 +28,19 @@ like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--critical=50'), qr{ERROR:.+must be a percentage}, $t);
+my $ver = $dbh->{pg_server_version};
+if ($ver >= 80400) {
+ SKIP: {
+ skip 'Cannot test fsm_pages completely on Postgres 8.4 or higher', 3;
+ }
+
+ $t=qq{$S gives an unknown when running against a 8.4 or higher version};
+ like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_pages}, $t);
+
+ exit;
+
+}
+
## Create a fake fsm 'view' for testing
$cp->set_fake_schema();
my $schema = $cp->get_fake_schema();
@@ -56,19 +69,6 @@ CREATE TABLE $schema.pg_freespacemap_relations (
});
$dbh->commit();
-my $ver = $dbh->{pg_server_version};
-if ($ver >= 80400) {
- SKIP: {
- skip 'Cannot test fsm_pages completely on Postgres 8.4 or higher', 3;
- }
-
- $t=qq{$S gives an unknown when running against a 8.4 or higher version};
- like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_pages}, $t);
-
- exit;
-
-}
-
$t=qq{$S gives normal output for empty tables};
like ($cp->run('--warning=10%'), qr{^$label OK: .+fsm page slots used: 0 of \d+}, $t);
diff --git a/t/02_fsm_relations.t b/t/02_fsm_relations.t
index ebb21c253..0eedc24ce 100644
--- a/t/02_fsm_relations.t
+++ b/t/02_fsm_relations.t
@@ -28,6 +28,18 @@ like ($cp->run('--warning=40'), qr{ERROR:.+must be a percentage}, $t);
$t=qq{$S fails when called with an invalid option};
like ($cp->run('--critical=50'), qr{ERROR:.+must be a percentage}, $t);
+my $ver = $dbh->{pg_server_version};
+if ($ver >= 80400) {
+ SKIP: {
+ skip 'Cannot test fsm_relations completely on Postgres 8.4 or higher', 3;
+ }
+
+ $t=qq{$S gives an unknown when running against a 8.4 or higher version};
+ like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_relations}, $t);
+
+ exit;
+}
+
## Create a fake fsm 'view' for testing
$cp->set_fake_schema();
my $schema = $cp->get_fake_schema();
@@ -56,18 +68,6 @@ CREATE TABLE $schema.pg_freespacemap_relations (
});
$dbh->commit();
-my $ver = $dbh->{pg_server_version};
-if ($ver >= 80400) {
- SKIP: {
- skip 'Cannot test fsm_relations completely on Postgres 8.4 or higher', 3;
- }
-
- $t=qq{$S gives an unknown when running against a 8.4 or higher version};
- like ($cp->run('--warning=10%'), qr{^$label UNKNOWN.*Cannot check fsm_relations}, $t);
-
- exit;
-}
-
$t=qq{$S gives normal output for empty tables};
like ($cp->run('--warning=10%'), qr{^$label OK: .+fsm relations used: 0 of \d+}, $t);
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 1c60f3959..6c8cf97f7 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -590,7 +590,6 @@ sub drop_schema_if_exists {
my $dbh = $self->{dbh} || die;
$name ||= $fakeschema;
- return;
if (! exists $self->{keep_old_schema}) {
$SQL = 'SELECT count(*) FROM pg_namespace WHERE nspname = ' . $dbh->quote($name);
my $count = $dbh->selectall_arrayref($SQL)->[0][0];