summaryrefslogtreecommitdiffstats
path: root/t/041_upgrade_custompaths.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:02:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:02:19 +0000
commite308bcff5a610d6a3bbe33b3769f03f6d4533b16 (patch)
tree6a8ed4eb26cd55f3a24165bc1d9b9a1f0ab62e8c /t/041_upgrade_custompaths.t
parentInitial commit. (diff)
downloadpostgresql-common-e308bcff5a610d6a3bbe33b3769f03f6d4533b16.tar.xz
postgresql-common-e308bcff5a610d6a3bbe33b3769f03f6d4533b16.zip
Adding upstream version 248.upstream/248upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/041_upgrade_custompaths.t')
-rw-r--r--t/041_upgrade_custompaths.t51
1 files changed, 51 insertions, 0 deletions
diff --git a/t/041_upgrade_custompaths.t b/t/041_upgrade_custompaths.t
new file mode 100644
index 0000000..3416b55
--- /dev/null
+++ b/t/041_upgrade_custompaths.t
@@ -0,0 +1,51 @@
+# Test cluster upgrade with a custom data directory and custom log file.
+
+use strict;
+
+use lib 't';
+use TestLib;
+use PgCommon;
+use Test::More tests => (@MAJORS == 1) ? 1 : 28;
+
+if (@MAJORS == 1) {
+ pass 'only one major version installed, skipping upgrade tests';
+ exit 0;
+}
+
+ok ((system "pg_createcluster --start --datadir /tmp/postgresql-test -l /tmp/postgresql-test.log $MAJORS[0] upgr >/dev/null") == 0);
+
+# Upgrade to latest version
+my $outref;
+is ((exec_as 0, "pg_upgradecluster -v $MAJORS[-1] $MAJORS[0] upgr", $outref, 0), 0, 'pg_upgradecluster succeeds');
+like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup';
+like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation';
+
+# Check clusters
+like_program_out 'nobody', 'pg_lsclusters -h', 0,
+ qr"$MAJORS[0] +upgr 5433 down postgres /tmp/postgresql-test +/tmp/postgresql-test.log\n$MAJORS[-1] +upgr 5432 online postgres /var/lib/postgresql/$MAJORS[-1]/upgr +/var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log", 'pg_lsclusters output';
+
+# clean away new cluster and restart the old one
+is ((system "pg_dropcluster $MAJORS[-1] upgr --stop"), 0, 'Dropping upgraded cluster');
+is_program_out 0, "pg_ctlcluster $MAJORS[0] upgr start", 0, '', 'Restarting old cluster';
+is_program_out 'nobody', 'pg_lsclusters -h', 0,
+ "$MAJORS[0] upgr 5433 online postgres /tmp/postgresql-test /tmp/postgresql-test.log
+", 'pg_lsclusters output';
+
+# Do another upgrade with using a custom defined data directory (and in passing, test --keep-port)
+my $outref;
+is ((exec_as 0, "pg_upgradecluster --keep-port -v $MAJORS[-1] $MAJORS[0] upgr /tmp/psql-common-testsuite", $outref, 0), 0, 'pg_upgradecluster succeeds');
+unlike $$outref, qr/^pg_restore: /m, 'no pg_restore error messages during upgrade';
+unlike $$outref, qr/^[A-Z]+: /m, 'no server error messages during upgrade';
+like $$outref, qr/Starting upgraded cluster/, 'pg_upgradecluster reported cluster startup';
+like $$outref, qr/Success. Please check/, 'pg_upgradecluster reported successful operation';
+
+like_program_out 'nobody', 'pg_lsclusters -h', 0,
+ qr"$MAJORS[0] +upgr 5433 down postgres /tmp/postgresql-test +/tmp/postgresql-test.log\n$MAJORS[-1] +upgr 5432 online postgres /tmp/psql-common-testsuite +/var/log/postgresql/postgresql-$MAJORS[-1]-upgr.log", 'pg_lsclusters output';
+
+# stop servers, clean up
+is ((system "pg_dropcluster $MAJORS[0] upgr"), 0, 'Dropping original cluster');
+is ((system "pg_dropcluster $MAJORS[-1] upgr --stop"), 0, 'Dropping upgraded cluster');
+
+check_clean;
+
+# vim: filetype=perl