[check_postgres] [commit] Allow use of custom PG_CTL, make sure we create test user.
check_postgres at bucardo.org
check_postgres at bucardo.org
Fri Apr 24 23:27:17 UTC 2009
Committed by Greg Sabino Mullane <greg at endpoint.com>
Allow use of custom PG_CTL, make sure we create test user.
---
t/CP_Testing.pm | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index bf8b1a6..20cbb24 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -119,7 +119,9 @@ sub test_database_handle {
unlink $logfile;
- $com = qq{LC_ALL=en LANG=C pg_ctl -o '-k socket' -l $logfile -D "$dbdir/data" start};
+ my $pg_ctl = $ENV{PG_CTL} || 'pg_ctl';
+
+ $com = qq{LC_ALL=en LANG=C $pg_ctl -o '-k socket' -l $logfile -D "$dbdir/data" start};
eval {
$info = qx{$com};
};
@@ -155,7 +157,19 @@ sub test_database_handle {
my $dsn = qq{dbi:Pg:host=$dbhost;dbname=$self->{dbname}};
my $dbuser = $self->{testuser};
my @superdsn = ($dsn, $dbuser, '', {AutoCommit=>0,RaiseError=>1,PrintError=>0});
- my $dbh = DBI->connect(@superdsn);
+ my $dbh;
+ eval {
+ $dbh = DBI->connect(@superdsn);
+ };
+ if ($@) {
+ if ($@ =~ /role .+ does not exist/) {
+ my @tempdsn = ($dsn, '', '', {AutoCommit=>1,RaiseError=>1,PrintError=>0});
+ my $tempdbh = DBI->connect(@tempdsn);
+ $tempdbh->do("CREATE USER $dbuser SUPERUSER");
+ $tempdbh->disconnect();
+ $dbh = DBI->connect(@superdsn);
+ }
+ }
$dbh->ping() or die qq{Failed to ping!\n};
$dbh->{AutoCommit} = 1;
--
1.6.0.5
More information about the Check_postgres
mailing list