$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';
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.
-----BEGIN PGP SIGNATURE-----
-iEYEABEDAAYFAkmjWs8ACgkQvJuQZxSWSsiRPwCfZc7WWECYzxNCM2TvCEVUWMkA
-ZZQAoL+0pEfXuu4MCkNJWm+dq7g6eAYU
-=L1hr
+iEYEABEDAAYFAkn2POAACgkQvJuQZxSWSsjFFwCeNLfR1C0kd4f2YKTnlvaapm3e
+6IsAoJQmPHbo18rsn8fkXSMz5wfMTHla
+=ZZQS
-----END PGP SIGNATURE-----
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();
$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};
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});
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;
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 (
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 (
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;
$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();
}
$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);
$t .= ' (mrtg)';
like ($cp->run('-c 100000 --output=mrtg'), qr{\d+\n0\n\nDB: ardala}, $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;
checksum
cp
dbh
+dbstats
DBI
DSN
fsm
} ## 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;