summaryrefslogtreecommitdiffstats
path: root/t/130_nonroot_admin.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:48:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:48:40 +0000
commit73e1fa4347d6c81c6e64054957ab436fa358ced1 (patch)
treef1cf86462dba1a85afd6005fca0a45b7e574c23c /t/130_nonroot_admin.t
parentInitial commit. (diff)
downloadpostgresql-common-upstream.tar.xz
postgresql-common-upstream.zip
Adding upstream version 200+deb10u5.upstream/200+deb10u5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/130_nonroot_admin.t')
-rw-r--r--t/130_nonroot_admin.t51
1 files changed, 51 insertions, 0 deletions
diff --git a/t/130_nonroot_admin.t b/t/130_nonroot_admin.t
new file mode 100644
index 0000000..312d694
--- /dev/null
+++ b/t/130_nonroot_admin.t
@@ -0,0 +1,51 @@
+# Check that cluster administration works as non-root if the invoker has
+# sufficient permissions on directories.
+
+use strict;
+
+use lib 't';
+use TestLib;
+
+my $version = $MAJORS[-1];
+my $oldversion = $MAJORS[0];
+
+use Test::More tests => 22;
+use PgCommon;
+
+my $testuser = 'postgres';
+my ($uid, $gid) = (getpwnam $testuser)[2,3];
+
+# pg_createcluster and pg_ctlcluster
+is ((exec_as $testuser, "pg_createcluster $version main --start"), 0,
+ "pg_createcluster succeeds as user $testuser with appropriate owner permissions");
+
+like_program_out $testuser, 'pg_lsclusters -h', 0, qr/^$version\s+main.*online/m;
+like_program_out 'postgres', 'psql -Atl', 0, qr/template1.*UTF8/;
+
+# pg_dropcluster
+is ((exec_as $testuser, "pg_dropcluster $version main --stop"), 0,
+ "pg_dropcluster succeeds as user $testuser with appropriate directory owner permissions");
+
+# pg_upgradecluster
+SKIP: {
+ skip 'Only one major version installed, skipping pg_upgradecluster tests', 8 if ($oldversion eq $version);
+
+ is ((exec_as $testuser, "pg_createcluster $oldversion main --start"), 0,
+ "pg_createcluster succeeds as user $testuser with appropriate group permissions");
+ my $outref;
+ is ((exec_as $testuser, "pg_upgradecluster -v $version $oldversion main", $outref, 0), 0,
+ "pg_upgradecluster succeeds as user $testuser");
+ like $$outref, qr/Starting target cluster/, 'pg_upgradecluster reported cluster startup';
+ like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation';
+
+ like_program_out $testuser, 'pg_lsclusters -h', 0,
+ qr/^$oldversion\s+main.*down.*\n^$version\s+main.*online/m;
+
+ # clean up
+ is ((exec_as $testuser, "pg_dropcluster $oldversion main"), 0);
+ is ((exec_as $testuser, "pg_dropcluster $version main --stop"), 0);
+}
+
+check_clean;
+
+# vim: filetype=perl