Commit ee43fed5 authored by Martin Pitt's avatar Martin Pitt

* t/*.t: Various small adaptions to work with 8.2, too.

parent a6f70b42
......@@ -5,8 +5,6 @@ postgresql-common (63) unstable; urgency=low
* pg_createcluster: Add configure_8_2().
* pg_ctlcluster, check_running_postmaster(): Check for both 'postmaster' and
'postgres' processes to also work for 8.2.
* t/010_defaultport_cluster.t: Make output test less strict to also catch
beta PostgreSQL versions.
* t/TestLib.pm, check_clean(): Also check for running 'postgres' processes
(since that's how the server is called in 8.2+). Update number of tests
everywhere.
......@@ -14,6 +12,7 @@ postgresql-common (63) unstable; urgency=low
ports like '54321' do not match.
* t/TestLib.pm, pidof(): Make pidof() strict enough to not catch the stats
collector and writer subprocesses.
* t/*.t: Various small adaptions to work with 8.2, too.
-- Martin Pitt <mpitt@debian.org> Tue, 26 Sep 2006 11:04:25 +0200
......
......@@ -37,7 +37,7 @@ sub check_major {
}
# verify that exactly one postmaster is running
my @pm_pids = pidof 'postmaster';
my @pm_pids = pidof (($v ge '8.2') ? 'postgres' : 'postmaster');
is $#pm_pids, 0, 'Exactly one postmaster process running';
# check environment
......@@ -60,7 +60,7 @@ sub check_major {
is_program_out 'postgres', "pg_ctlcluster $v main restart", 0, '',
'cluster restarts with new environment file';
@pm_pids = pidof 'postmaster';
@pm_pids = pidof (($v ge '8.2') ? 'postgres' : 'postmaster');
is $#pm_pids, 0, 'Exactly one postmaster process running';
%env = pid_env $pm_pids[0];
is $env{'PGEXTRAVAR1'}, '1', 'correct value of PGEXTRAVAR1 in environment';
......@@ -72,7 +72,7 @@ sub check_major {
'Socket, but not PID file in /var/run/postgresql/';
# verify that the correct client version is selected
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $v\.\d/,
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $v/,
'pg_wrapper selects version number of cluster';
# verify that the cluster is displayed
......
......@@ -6,7 +6,7 @@ require File::Temp;
use lib 't';
use TestLib;
use Test::More tests => 125;
use Test::More tests => 131;
use lib '/usr/share/postgresql-common';
use PgCommon;
......@@ -117,6 +117,8 @@ is_program_out 'postgres', "pg_ctlcluster $version main start", 0,
like_program_out 'postgres', 'pg_lsclusters -h', 0, qr/online/, 'cluster is online';
is ((exec_as 'postgres', "pg_ctlcluster $version main stop"), 0,
'pg_ctlcluster stop succeeds');
like_program_out 'postgres', 'pg_lsclusters -h', 0, qr/down/, 'cluster is down';
ok (! -e "/var/lib/postgresql/$version/main/postmaster.pid", 'no pid file left');
# corrupt PID file while server is down
create_foo_pid;
......
......@@ -89,9 +89,10 @@ sub check_cluster {
'printf "set client_encoding=\'SJIS\'; select \'\\\\\\\'a\'" | psql -Atq template1',
0, qr/\\' is insecure/,
'Server rejects \\\' escaping in unsafe client encoding (CVE-2006-2314)';
my $esc_warning = ($v ge '8.1') ? "set escape_string_warning='off';" : '';
is_program_out 'postgres',
'printf "set client_encoding=\'UTF-8\'; select \'\\\\\\\'a\'" | psql -Atq template1',
0, "'a\n", 'Server accepts \\\' escaping in safe client encoding (CVE-2006-2314)';
"printf \"set client_encoding='UTF-8'; $esc_warning select '\\\\\\'a'\" | psql -Atq template1",
0, "'a\n", 'Server accepts \\\' escaping in safe client encoding (CVE-2006-2314)';
}
# drop cluster
......
......@@ -20,8 +20,9 @@ for my $v (@MAJORS[0, -1]) {
qr/^$v\s+main\s+5432\s+online\s+$owner/,
'pg_lsclusters shows running cluster';
like ((ps 'postmaster'), qr/^$owner.*bin\/postmaster .*\/var\/lib\/postgresql\/$v\/main/,
"postmaster is running as user $owner");
my $master_process = ($v ge '8.2') ? 'postgres' : 'postmaster';
like ((ps $master_process), qr/^$owner.*bin\/$master_process .*\/var\/lib\/postgresql\/$v\/main/m,
"$master_process is running as user $owner");
is_program_out $owner, 'ls /tmp/.s.PGSQL.*', 0, "/tmp/.s.PGSQL.5432\n/tmp/.s.PGSQL.5432.lock\n", 'socket is in /tmp';
......
......@@ -68,10 +68,10 @@ if (-f '/etc/postgresql-common/user_clusters') {
}
# check basic cluster selection
like_program_out 0, 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]\.\d+\b/,
like_program_out 0, 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]/,
'pg_wrapper selects port 5432 as default cluster';
like_program_out 0, "psql --cluster $new1 --version", 0,
qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
'pg_wrapper --cluster works';
like_program_out 0, "psql --cluster $MAJORS[-1]/foo --version", 1,
qr/Specified cluster does not exist/,
......@@ -93,7 +93,7 @@ unlike_program_out 'postgres', "psql -Atl", 0, qr/test\|postgres\|/,
is_program_out 'postgres', "psql --cluster $MAJORS[0]/127.0.0.1: -Atc 'show port' template1", 0, "5432\n",
"psql --cluster $MAJORS[0]/127.0.0.1: defaults to port 5432";
like_program_out 'postgres', "psql --cluster $MAJORS[-1]/127.0.0.1:5432 --version", 0,
qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
"psql --cluster $MAJORS[-1]/127.0.0.1:5432 uses latest client version";
like_program_out 'postgres', "psql -Atl --cluster $MAJORS[-1]/localhost:5434", 0,
qr/test\|postgres\|/, "test db appears in cluster $MAJORS[-1]/localhost:5434";
......@@ -122,7 +122,7 @@ like_program_out 'postgres', "psql -l", 1,
qr/Invalid version specified with \$PGCLUSTER/,
'invalid PGCLUSTER value';
$ENV{'PGCLUSTER'} = "$MAJORS[-1]/127.0.0.1:";
like_program_out 0, 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
like_program_out 0, 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
'PGCLUSTER network cluster selection (1)';
$ENV{'PGCLUSTER'} = "$MAJORS[-1]/localhost:5434";
like_program_out 'postgres', 'psql -Atl', 0,
......@@ -145,7 +145,7 @@ is_program_out 'postgres', 'psql -Atc "show port" template1', 0, "5432\n",
$ENV{'PGCLUSTER'} = $new2;
delete $ENV{'PGPORT'};
$ENV{'PGPORT'} = '5432';
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
'PGPORT+PGCLUSTER, PGCLUSTER selects version';
is_program_out 'postgres', 'psql -Atc "show port" template1', 0, "5432\n",
'PGPORT+PGCLUSTER, PGPORT selects port';
......@@ -162,10 +162,10 @@ delete $ENV{'PGDATABASE'};
open F, '>/etc/postgresql-common/user_clusters' or die "Could not create user_clusters: $!";
close F;
chmod 0644, '/etc/postgresql-common/user_clusters';
like_program_out 0, 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]\.\d+\b/,
like_program_out 0, 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]/,
'pg_wrapper selects port 5432 as default cluster with empty user_clusters';
like_program_out 0, "psql --cluster $new1 --version", 0,
qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
'pg_wrapper --cluster works with empty user_clusters';
# check default cluster selection with user_clusters
......@@ -173,7 +173,7 @@ open F, '>/etc/postgresql-common/user_clusters' or die "Could not create user_cl
print F "* * $MAJORS[-1] new1 *\n";
close F;
chmod 0644, '/etc/postgresql-common/user_clusters';
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
"pg_wrapper selects correct cluster with user_clusters '* * $MAJORS[-1] new1 *'";
# check default database selection with user_clusters
......@@ -194,9 +194,9 @@ open F, '>/etc/postgresql-common/user_clusters' or die "Could not create user_cl
print F "postgres * $MAJORS[-1] new1 *\nnobody * $MAJORS[0] old *\n* * 5.5 * *";
close F;
chmod 0644, '/etc/postgresql-common/user_clusters';
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
'pg_wrapper selects correct cluster with per-user user_clusters';
like_program_out 'nobody', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]\.\d+\b/,
like_program_out 'nobody', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]/,
'pg_wrapper selects correct cluster with per-user user_clusters';
like_program_out 0, 'psql --version', 1, qr/user_clusters.*line 3.*version.*not exist/i,
'pg_wrapper error for invalid per-user user_clusters line';
......@@ -207,9 +207,9 @@ open F, '>/etc/postgresql-common/user_clusters' or die "Could not create user_cl
print F "postgres * $MAJORS[0] localhost: *\nnobody * $MAJORS[-1] new1 *\n* * $MAJORS[-1] localhost:a *";
close F;
chmod 0644, '/etc/postgresql-common/user_clusters';
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]\.\d+\b/,
like_program_out 'postgres', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[0]/,
'pg_wrapper selects correct version with per-user user_clusters';
like_program_out 'nobody', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]\.\d+\b/,
like_program_out 'nobody', 'psql --version', 0, qr/^psql \(PostgreSQL\) $MAJORS[-1]/,
'pg_wrapper selects correct version with per-user user_clusters';
like_program_out 0, 'psql --version', 1, qr/user_clusters.*line 3.*cluster.*not exist/i,
'pg_wrapper error for invalid per-user user_clusters line';
......
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