Many test cleanups and changes.
authorGreg Sabino Mullane <greg@endpoint.com>
Mon, 27 Apr 2009 23:30:24 +0000 (19:30 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Mon, 27 Apr 2009 23:30:24 +0000 (19:30 -0400)
14 files changed:
check_postgres.pl
check_postgres.pl.asc
t/02_checkpoint.t
t/02_database_size.t
t/02_disabled_triggers.t
t/02_disk_space.t
t/02_fsm_pages.t
t/02_fsm_relations.t
t/02_relation_size.t
t/02_sequence.t
t/02_txn_wraparound.t
t/02_version.t
t/99_spellcheck.t
t/CP_Testing.pm

index 06a934dde69baecc08796a400ed92ff268714da0..737fe4bf8eb30732d17320d9299736b89a90a5d0 100755 (executable)
@@ -4356,7 +4356,7 @@ sub check_checkpoint {
        $db->{host} = '<none>';
 
        ## Run pg_controldata, grab the time
-       my $pgc 
+       my $pgc
                = $ENV{PGCONTROLDATA} ? $ENV{PGCONTROLDATA}
                : $ENV{PGBINDIR}      ? "$ENV{PGBINDIR}/pg_controldata"
                :                       'pg_controldata';
@@ -5112,7 +5112,7 @@ the C<--datadir> argument. It returns the number of seconds since the last check
 was run, as determined by parsing the call to C<pg_controldata>. Because of this, the 
 pg_controldata executable must be available in the current path. Alternatively, you can 
 set the environment variable C<PGCONTROLDATA> to the exact location of the pg_controldata 
-excutable, or you can specify C<PGBINDIR> as the directory that it lives in.
+executable, or you can specify C<PGBINDIR> as the directory that it lives in.
 
 At least one warning or critical argument must be set.
 
index 4579e89b81cd0d33fc1ea16fb3a3e3e00867cbab..9ebb368ba4bff42b78790e1cb5092914426cc58b 100644 (file)
@@ -1,6 +1,6 @@
 -----BEGIN PGP SIGNATURE-----
 
-iEYEABEDAAYFAkmjWs8ACgkQvJuQZxSWSsiRPwCfZc7WWECYzxNCM2TvCEVUWMkA
-ZZQAoL+0pEfXuu4MCkNJWm+dq7g6eAYU
-=L1hr
+iEYEABEDAAYFAkn2POAACgkQvJuQZxSWSsjFFwCeNLfR1C0kd4f2YKTnlvaapm3e
+6IsAoJQmPHbo18rsn8fkXSMz5wfMTHla
+=ZZQS
 -----END PGP SIGNATURE-----
index 7021a201024118bd1be95d4fb0e48dbae3036988..b345178fa0daff3de2086e9803124c6e05274230 100644 (file)
@@ -39,7 +39,7 @@ like ($cp->run('-c 10 --datadir=foobar'), qr{ERROR: Invalid data_directory}, $t)
 
 my $host = $cp->get_host();
 $t=qq{$S fails when called against a non datadir datadir};
-like ($cp->run("-c 10 --datadir=$host"), qr{ERROR: Call to pg_controldata}, $t);
+like ($cp->run("-c 10 --datadir=$host"), qr{ERROR:.+could not read the given data directory}, $t);
 
 $t=qq{$S works when called for a recent checkpoint};
 my $dbh = $cp->get_dbh();
index f13b16e36f884edf4af894df3a32e4426ba1026c..f84de05bd804b05ded8b377f03da7310ce388ca6 100644 (file)
@@ -20,6 +20,8 @@ my $S = q{Action 'database_size'};
 $t=qq{$S returned expected text when no warning/critical size is provided};
 like ($cp->run(''), qr{^ERROR: Must provide a warning and/or critical size}, $t);
 
+$cp->drop_all_tables();
+
 for my $type (qw/b bs k kb kbs m mb mbs g gb gbs t tb tbs p pb pbs e eb ebs z zb zbs/) {
        my $opt = "-w 9999999$type";
        $t=qq{$S returned expected text when warning level is specified in $type};
index 23507e26f8bb0691a2b0a86f12ec0c2bfa954e53..5ed391b09f12f1984aff1a5fcdd99500d4d79654 100644 (file)
@@ -50,14 +50,17 @@ for (-1, 0, 'a') {
     like ($cp->run(qq{-c $_}), qr/ERROR: Invalid argument.*must be a positive integer/, $t . " ($_)");
 }
 
-# Set up a test table with two triggers.
-$dbh->do(qq{CREATE TABLE "$testtbl" (a integer)});
-END {
+sub cleanup {
     $dbh->rollback;
-    $dbh->do(qq{DROP TABLE IF EXISTS "$testtbl"});
+       local $dbh->{Warn} = 0;
+       $dbh->do(qq{DROP TABLE IF EXISTS "$testtbl"});
     $dbh->do(qq{DROP FUNCTION IF EXISTS "${testtrig_prefix}func"()});
     $dbh->commit;
 }
+END { cleanup(); }
+# Set up a test table with two triggers.
+cleanup();
+$dbh->do(qq{CREATE TABLE "$testtbl" (a integer)});
 
 $dbh->do(qq{CREATE FUNCTION "${testtrig_prefix}func"() RETURNS TRIGGER AS 'BEGIN return null; END' LANGUAGE plpgsql});
 
index 6eeff2c20a250d9b8313a2042049923995ca7508..40dbd60f5d23219878d55d056913ccc883e56a5a 100644 (file)
@@ -6,8 +6,7 @@ use strict;
 use warnings;
 use Data::Dumper;
 use DBI;
-use Test::More qw(no_plan);
-END { diag "Don't forget to make a plan!" }
+use Test::More tests => 7;
 use lib 't','.';
 use CP_Testing;
 
index 8ad70ca14185c174a1cb44b5fab67e508a8e7e52..105be217452ed547c33a147f3dbd81cb3ffcb9a8 100644 (file)
@@ -34,6 +34,7 @@ my $schema = $cp->get_fake_schema();
        local $dbh->{Warn};
        $dbh->do("DROP TABLE IF EXISTS $schema.pg_freespacemap_pages");
        $dbh->do("DROP TABLE IF EXISTS $schema.pg_freespacemap_relations");
+       $dbh->do('DROP FUNCTION IF EXISTS public.version()');
 }
 $dbh->do(qq{
 CREATE TABLE $schema.pg_freespacemap_pages (
index c0afe375903b6cff1f972af77ce7396549fc3d0a..9f0e66ac2aa5abdde9b848a9270b7ac4934624c7 100644 (file)
@@ -34,6 +34,7 @@ my $schema = $cp->get_fake_schema();
        local $dbh->{Warn};
        $dbh->do("DROP TABLE IF EXISTS $schema.pg_freespacemap_pages");
        $dbh->do("DROP TABLE IF EXISTS $schema.pg_freespacemap_relations");
+       $dbh->do('DROP FUNCTION IF EXISTS public.version()');
 }
 $dbh->do(qq{
 CREATE TABLE $schema.pg_freespacemap_pages (
index acc3c101e7d45e3908be2b2671b119e72ce365cd..f4289e4c3b1093dee69a5ee0b8e953da365d1bcf 100644 (file)
@@ -53,11 +53,7 @@ $t = qq{$S detects no matching tables due to unknown user};
 like ($cp->run(q{-w 1 --includeuser foo}), qr{$label OK:.*No matching entries found due to user exclusion/inclusion options}, $t);
 
 ## We need to remove all tables to make this work correctly
-local $dbh->{Warn} = 0;
-my @info = $dbh->tables('','public','','TABLE');
-for my $tab (@info) {
-       $dbh->do("DROP TABLE $tab CASCADE");
-}
+$cp->drop_all_tables();
 $dbh->do(qq{CREATE TABLE $testtbl (a integer)});
 
 $dbh->commit;
index 2517e3fd8ecdd808f7e9f50bc9897f08792d1326..a67e095a9d2908a980f9d4ec3399a0451eb9d103 100644 (file)
@@ -41,7 +41,7 @@ $dbh->do("CREATE TEMP SEQUENCE ${seqname}2");
 $dbh->commit();
 
 $t=qq{$S fails when sequence not readable};
-like ($cp->run(''), qr{ERROR: Could not determine}, $t);
+like ($cp->run(''), qr{ERROR:\s*(?:Could not determine|cannot access temporary)}, $t);
 
 $dbh->do("CREATE SEQUENCE $seqname");
 $dbh->commit();
index a93c7869d505ee180e310d0e2cdfbc2caef22ae8..130dd5ae890163f829728fce249c5bd8fb5fb943 100644 (file)
@@ -54,7 +54,7 @@ for (-1, 0, 'a') {
 }
 
 $t = qq{$S sees impending wrap-around};
-like ($cp->run('-c ' . ($txn_measure / 2)), qr/$label CRITICAL/, $t);
+like ($cp->run('-c ' . int ($txn_measure / 2)), qr/$label CRITICAL/, $t);
 
 $t = qq{$S sees no impending wrap-around};
 like ($cp->run('-v -c ' . ($txn_measure * 2)), qr/$label OK/, $t);
@@ -62,4 +62,3 @@ like ($cp->run('-v -c ' . ($txn_measure * 2)), qr/$label OK/, $t);
 $t .= ' (mrtg)';
 like ($cp->run('-c 100000 --output=mrtg'), qr{\d+\n0\n\nDB: ardala}, $t);
 
-
index 143cf9094860b80c0828698331b230bb9ce65999..e37408b1456391d879793ddfde18020f04c38656 100644 (file)
@@ -108,7 +108,7 @@ is ($cp->run('--output=MRTG --mrtg=7.8.12'), qq{1\n0\n\n7.8.12\n}, $t);
 
 local $dbh->{Warn} = 0;
 $dbh->do('DROP SCHEMA cptest CASCADE');
-$dbh->do('DROP FUNCTION public.version()');
+$dbh->do('DROP FUNCTION IF EXISTS public.version()');
 $cp->reset_path();
 
 exit;
index a66a5e0864ee332324357cae970d5472a29bbd7e..147e8483e8a1da4061afdb364c99364ed7c9cea9 100644 (file)
@@ -140,6 +140,7 @@ bucardo
 checksum
 cp
 dbh
+dbstats
 DBI
 DSN
 fsm
index f0528161daf5f39550af14efd89c0c6614fa4d66..c76df0f0882eaa74774689837e0956c3ed7ed038 100644 (file)
@@ -491,4 +491,17 @@ sub reset_path {
 
 } ## end of reset_path
 
+sub drop_all_tables {
+
+       my $self = shift;
+       my $dbh = $self->{dbh} || die;
+       local $dbh->{Warn} = 0;
+       my @info = $dbh->tables('','public','','TABLE');
+       for my $tab (@info) {
+               $dbh->do("DROP TABLE $tab CASCADE");
+       }
+       $dbh->commit();
+
+} ## end of drop_all_tables
+
 1;