summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Sabino Mullane2009-05-01 20:08:57 +0000
committerGreg Sabino Mullane2009-05-01 20:08:57 +0000
commit3a1c45a24f0890c1a78535dfabf0287942a3b848 (patch)
treef135b621bbdb9cc7a90436838ffdba8f0ef6e1db
parent81d2796bf50531df6cc19b4e8ae5ae57bfbc462a (diff)
Wacky workaround for psql -h bug.
-rw-r--r--Makefile.PL2
-rw-r--r--t/02_checkpoint.t2
-rw-r--r--t/CP_Testing.pm29
3 files changed, 29 insertions, 4 deletions
diff --git a/Makefile.PL b/Makefile.PL
index f7cc3af0e..3190c482d 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -53,7 +53,7 @@ my %opts =
NO_META => 1,
NORECURS => 1,
MAN1PODS => {},
- clean => { FILES => 'test_database_check_postgres/' },
+ clean => { FILES => 'test_database_check_postgres/', '/tmp/cptesting_socket' },
);
{
diff --git a/t/02_checkpoint.t b/t/02_checkpoint.t
index a83c05196..de342ba69 100644
--- a/t/02_checkpoint.t
+++ b/t/02_checkpoint.t
@@ -38,7 +38,7 @@ like ($cp->run('-c 10'), qr{^ERROR: Must supply a --datadir}, $t);
$t=qq{$S fails when called with an invalid datadir option and PGDATA is not set};
like ($cp->run('-c 10 --datadir=foobar'), qr{^ERROR: Invalid data_directory}, $t);
-my $host = $cp->get_host();
+my $host = $cp->get_dbhost();
$t=qq{$S fails when called against a non datadir datadir};
like ($cp->run(qq{-c 10 --datadir="$host"}), qr{^ERROR:.+could not read the given data directory}, $t);
diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index 3cc2ed1bd..2793cdbef 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -204,6 +204,18 @@ sub test_database_handle {
my $dbhost = $self->{dbhost} = "$here/$dbdir/data space/socket";
$dbhost =~ s/^ /\\ /;
$dbhost =~ s/([^\\]) /$1\\ /g;
+
+ ## Workaround for bug where psql -h /some/long/path fails
+ if (length($dbhost) > 90) {
+ my $newname = '/tmp/cptesting_socket';
+ if (! -e $newname) {
+ warn "Creating new symlink socket at $newname\n";
+ (my $oldname = $dbhost) =~ s/\\//g;
+ symlink $oldname => $newname;
+ }
+ $dbhost = $self->{shorthost} = $newname;
+ }
+
$self->{dbname} ||= 'postgres';
my $dsn = qq{dbi:Pg:host=$dbhost;dbname=$self->{dbname}};
my $dbuser = $self->{testuser};
@@ -220,6 +232,9 @@ sub test_database_handle {
$tempdbh->disconnect();
$dbh = DBI->connect(@superdsn);
}
+ else {
+ die "Could not connect: $@\n";
+ }
}
$dbh->ping() or die qq{Failed to ping!\n};
@@ -300,7 +315,7 @@ sub run {
my $double = $action =~ s/DB2// ? 1 : 0;
- my $dbhost = $self->{dbhost} || die 'No dbhost?';
+ my $dbhost = $self->{shorthost} || $self->{dbhost} || die 'No dbhost?';
my $dbuser = $self->{testuser} || die 'No testuser?';
my $dbname = $self->{dbname} || die 'No dbname?';
my $com = qq{perl check_postgres.pl --action=$action --dbhost="$dbhost" --dbuser=$dbuser};
@@ -336,11 +351,21 @@ sub get_user {
return $self->{testuser};
}
-sub get_host {
+sub get_dbhost {
my $self = shift;
return $self->{dbhost};
}
+sub get_host {
+ my $self = shift;
+ return $self->{shorthost} || $self->{dbhost};
+}
+
+sub get_shorthost {
+ my $self = shift;
+ return $self->{shorthost};
+}
+
sub get_dbname {
my $self = shift;
return $self->{dbname};