[check_postgres] [commit] Yet more testing tweaks. The end is in sight.

check_postgres at bucardo.org check_postgres at bucardo.org
Thu Apr 30 20:33:17 UTC 2009


Committed by Greg Sabino Mullane <greg at endpoint.com>

Yet more testing tweaks. The end is in sight.

---
 t/02_fsm_pages.t   |    2 +-
 t/02_last_vacuum.t |    1 -
 t/02_locks.t       |    4 ++--
 t/99_perlcritic.t  |    5 +++++
 t/CP_Testing.pm    |   26 ++++++++++++++++++++++++--
 5 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/t/02_fsm_pages.t b/t/02_fsm_pages.t
index 9b884c3..5aa08bd 100644
--- a/t/02_fsm_pages.t
+++ b/t/02_fsm_pages.t
@@ -83,6 +83,6 @@ $t=qq{$S gives normal critical output};
 like ($cp->run('--critical=5%'), qr{^$label CRITICAL: .+fsm page slots used: 52288 of \d+}, $t);
 
 $t=qq{$S gives normal output for MRTG};
-is ($cp->run('--critical=5% --output=MRTG'), qq{34\n52288\n\n\n}, $t);
+is ($cp->run('--critical=5% --output=MRTG'), qq{52\n52288\n\n\n}, $t);
 
 exit;
diff --git a/t/02_last_vacuum.t b/t/02_last_vacuum.t
index e8d1bce..3761c7d 100644
--- a/t/02_last_vacuum.t
+++ b/t/02_last_vacuum.t
@@ -62,7 +62,6 @@ $dbh->{AutoCommit} = 1;
 $dbh->do('VACUUM');
 $cp->drop_table_if_exists($testtbl);
 $dbh->do(qq{CREATE TABLE $testtbl AS SELECT 123::INTEGER AS a FROM generate_series(1,200000)});
-$dbh->commit();
 
 like ($cp->run("-w 0 --exclude=~.* --include=$testtbl"),
 	  qr{No matching tables found due to exclusion}, $t);
diff --git a/t/02_locks.t b/t/02_locks.t
index ce1f0ae..1cb3ce3 100644
--- a/t/02_locks.t
+++ b/t/02_locks.t
@@ -27,7 +27,7 @@ like ($cp->run('--dbname=foo'), qr{database "foo" does not exist}, $t);
 $t=qq{$S fails when no matching databases found};
 like ($cp->run('--include=foo'), qr{No matching databases found}, $t);
 
-$cp->drop_schema_if_exists($fakeschema);
+$cp->drop_schema_if_exists();
 $cp->create_fake_pg_table('pg_locks');
 $SQL = q{SELECT oid FROM pg_database WHERE datname = 'postgres'};
 my $dboid = $dbh->selectall_arrayref($SQL)->[0][0];
@@ -72,6 +72,6 @@ $t=qq{$S returns correct multiple item output};
 like ($cp->run('--warning="waiting=1;exclusive=2"'),
 	  qr{POSTGRES_LOCKS WARNING.*total "waiting" locks: 1 \* total "exclusive" locks: 2 }, $t);
 
-$cp->drop_schema_if_exists($fakeschema);
+$cp->drop_schema_if_exists();
 
 exit;
diff --git a/t/99_perlcritic.t b/t/99_perlcritic.t
index 288d80a..d91264f 100644
--- a/t/99_perlcritic.t
+++ b/t/99_perlcritic.t
@@ -51,6 +51,11 @@ for my $filename (qw{check_postgres.pl t/CP_Testing.pm}) {
 		(my $policy = $v->policy()) =~ s/Perl::Critic::Policy:://;
 		my $source = $v->source();
 
+		if ($filename =~ /test/io) {
+			next VIO if $policy =~ /RequireArgUnpacking/o
+				or $policy =~ /RequireVersionVar/o;
+		}
+
 		$vios++;
 		my $f = $v->filename();
 		my $l = $v->location();
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index fd2880f..b4d9f78 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -108,7 +108,6 @@ sub test_database_handle {
 		close $cfh or die qq{Could not close "$cfile": $!\n};
 
 		mkdir "$dbdir/data space/socket";
-
 	}
 
 	## See if the database is already running.
@@ -143,7 +142,17 @@ sub test_database_handle {
 			: $ENV{PGBINDIR} ? "$ENV{PGBINDIR}/pg_ctl"
 			:                  'pg_ctl';
 
-		$com = qq{LC_ALL=en LANG=C $pg_ctl -o '-k socket' -l $logfile -D "$dbdir/data space" start};
+		if (qx{$pg_ctl --version} !~ /(\d+)\.(\d+)/) {
+			die qq{Could not determine the version of pg_ctl in use!\n};
+		}
+		my ($maj,$min) = ($1,$2);
+
+		my $sockdir = 'socket';
+		if ($maj < 8 or ($maj==8 and $min < 1)) {
+			$sockdir = qq{"$dbdir/data space/socket"};
+		}
+
+		$com = qq{LC_ALL=en LANG=C $pg_ctl -o '-k $sockdir' -l $logfile -D "$dbdir/data space" start};
 		eval {
 			$info = qx{$com};
 		};
@@ -169,6 +178,19 @@ sub test_database_handle {
 		}
 		close $logfh or die qq{Could not close "$logfile": $!\n};
 
+		if ($maj < 8 or ($maj==8 and $min < 1)) {
+			my $here = cwd();
+			my $host = "$here/$dbdir/data space/socket";
+			my $COM = qq{psql -d template1 -q -h "$host" -c "CREATE DATABASE postgres"};
+			system $COM;
+			my $newuser = $self->{testuser};
+			$COM = qq{psql -d template1 -q -h "$host" -c "CREATE USER $newuser"};
+			system $COM;
+			my $SQL = q{UPDATE pg_shadow SET usesuper='t' WHERE usename = 'check_postgres_testing'};
+			$COM = qq{psql -d template1 -q -h "$host" -c "$SQL"};
+			system $COM;
+		}
+
 	} ## end of needs startup
 
 	my $here = cwd();
-- 
1.6.0.5



More information about the Check_postgres mailing list