diff options
author | Greg Sabino Mullane | 2009-06-12 22:02:34 +0000 |
---|---|---|
committer | Greg Sabino Mullane | 2009-06-12 22:02:34 +0000 |
commit | bc4b3aebd7fe0686b10eca646567f021fde76370 (patch) | |
tree | be7afae58882954705bf2b69621b40b5ada00691 | |
parent | 54d7c17e8360d460c32c68cb552acc86f15d8045 (diff) |
Use "dbnum" for multiple databases, and make sure we cleanup symlinks as well.
-rw-r--r-- | t/02_same_schema.t | 3 | ||||
-rw-r--r-- | t/CP_Testing.pm | 32 |
2 files changed, 22 insertions, 13 deletions
diff --git a/t/02_same_schema.t b/t/02_same_schema.t index be523d351..4eea20cc3 100644 --- a/t/02_same_schema.t +++ b/t/02_same_schema.t @@ -13,8 +13,7 @@ use CP_Testing; use vars qw/$dbh1 $dbh2 $SQL $t $stdargs/; my $cp1 = CP_Testing->new({ default_action => 'same_schema' }); -my $cp2 = CP_Testing->new({ default_action => 'same_schema', - dbdir => $cp1->{dbdir} . '2' }); +my $cp2 = CP_Testing->new({ default_action => 'same_schema', dbnum => 2}); $dbh1 = $cp1->test_database_handle(); $dbh1->{AutoCommit} = 1; diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm index 5638cb1d1..a9cafd5fc 100644 --- a/t/CP_Testing.pm +++ b/t/CP_Testing.pm @@ -12,7 +12,6 @@ use Cwd; our $DEBUG = 0; our $MAX_HOST_PATH = 60; -our $next_socket_mod = 1; use vars qw/$com $info $count $SQL $sth/; @@ -29,6 +28,9 @@ sub new { if (exists $arg->{default_action}) { $self->{action} = $arg->{default_action}; } + if (exists $arg->{dbnum} and $arg->{dbnum}) { + $self->{dbdir} .= $arg->{dbnum}; + } return bless $self => $class; } @@ -38,15 +40,20 @@ sub cleanup { my $dbdir = $self->{dbdir} or die; for my $dirnum ('', '2', '3', '4', '5') { my $pidfile = "$dbdir$dirnum/data space/postmaster.pid"; - next if ! -e $pidfile; - open my $fh, '<', $pidfile or die qq{Could not open "$pidfile": $!\n}; - <$fh> =~ /^(\d+)/ or die qq{File "$pidfile" did not start with a number!\n}; - my $pid = $1; - close $fh or die qq{Could not close "$pidfile": $!\n}; - kill 15 => $pid; - sleep 1; - if (kill 0 => $pid) { - kill 9 => $pid; + if (-e $pidfile) { + open my $fh, '<', $pidfile or die qq{Could not open "$pidfile": $!\n}; + <$fh> =~ /^(\d+)/ or die qq{File "$pidfile" did not start with a number!\n}; + my $pid = $1; + close $fh or die qq{Could not close "$pidfile": $!\n}; + kill 15 => $pid; + sleep 1; + if (kill 0 => $pid) { + kill 9 => $pid; + } + } + my $symlink = "/tmp/cptesting_socket$dirnum"; + if (-l $symlink) { + unlink $symlink; } } @@ -244,7 +251,10 @@ sub test_database_handle { ## Workaround for bug where psql -h /some/long/path fails if (length($dbhost) > $MAX_HOST_PATH) { - my $newname = '/tmp/cptesting_socket' . ($next_socket_mod++); + my $newname = '/tmp/cptesting_socket'; + if ($self->{dbdir} =~ /(\d+)$/) { + $newname .= $1; + } if (! -e $newname) { warn "Creating new symlink socket at $newname\n"; (my $oldname = $dbhost) =~ s/\\//g; |