Commit 15492de9 authored by Martin Pitt's avatar Martin Pitt

* t/030_errors.t: Test graceful handling of absent /var/lib/postgresql.

  (Reproduces LP #210322)
* pg_ctlcluster: Check early whether the data directory exists and is
  accessible, to avoid lots of Perl warning clutter. (LP: #210322)
parent b7c7dc4e
......@@ -6,8 +6,12 @@ postgresql-common (88) UNRELEASED; urgency=low
* pg_ctlcluster: On stop, clean up stale/corrupt PID files if the server is
not running. Also fix a taint error and simplify the code a bit.
(Closes: #473879)
* t/030_errors.t: Test graceful handling of absent /var/lib/postgresql.
(Reproduces LP #210322)
* pg_ctlcluster: Check early whether the data directory exists and is
accessible, to avoid lots of Perl warning clutter. (LP: #210322)
-- Martin Pitt <mpitt@debian.org> Tue, 22 Apr 2008 23:13:51 +0200
-- Martin Pitt <mpitt@debian.org> Wed, 23 Apr 2008 17:40:38 +0200
postgresql-common (87) unstable; urgency=medium
......
......@@ -432,6 +432,10 @@ unless ($action eq 'stop' || $action eq 'autovac-stop') {
$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
unless (-d $info{'pgdata'} && defined $info{'owneruid'}) {
error $info{'pgdata'} . ' is not accessible or does not exist';
}
# check that owner uig/gid is valid
unless (getpwuid $info{'owneruid'}) {
error 'The cluster is owned by user id '.$info{'owneruid'}.' which does not exist any more'
......
......@@ -6,7 +6,7 @@ require File::Temp;
use lib 't';
use TestLib;
use Test::More tests => 146;
use Test::More tests => 154;
use lib '/usr/share/postgresql-common';
use PgCommon;
......@@ -220,6 +220,24 @@ like_program_out 'postgres', "pg_dropcluster $version main", 1,
qr/root privileges/, "pg_dropcluster fails as user postgres by default";
# remove cluster and directory
ok ((system "pg_dropcluster $version main") == 0,
'pg_dropcluster');
# graceful handling of absent data dir (might not be mounted)
ok ((system "pg_createcluster $version main >/dev/null") == 0,
"pg_createcluster succeeds");
rename "/var/lib/postgresql", "/var/lib/postgresql.orig" or die "rename: $!";
my $outref;
is ((exec_as 0, "pg_ctlcluster $version main start", $outref, 1), 1,
'pg_ctlcluster fails on nonexisting /var/lib/postgresql');
like $$outref, qr/^Error:.*\/var\/lib\/postgresql.*not accessible.*$/, 'proper error message for nonexisting /var/lib/postgresql';
rename "/var/lib/postgresql.orig", "/var/lib/postgresql" or die "rename: $!";
is_program_out 'postgres', "pg_ctlcluster $version main start", 0, '',
'pg_ctlcluster start succeeds again with reappeared /var/lib/postgresql';
is_program_out 'postgres', "pg_ctlcluster $version main stop", 0, '', 'stopping cluster';
# clean up
ok ((system "pg_dropcluster $version main") == 0,
'pg_dropcluster');
ok_dir $socketdir, [], 'No sockets any more';
......
......@@ -115,6 +115,7 @@ sub exec_as {
if (defined $_[3] && $_[3] != $result) {
print "command '$_[1]' did not exit with expected code $_[3]:\n";
print $out;
fail_debug;
}
return $result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment