postgres.git / summary / log / commit / refs
commit 88aa6ca138a1eaa63618b2e6ef85ca6c7422dfed
Author: Michael Paquier <michael@paquier.xyz>
Date: Thu Sep 03 08:28:53 2026 +0000
pg_upgrade: Test --check with a running source server
4fff78f009 has added coverage for pg_upgrade --check, but only after
stopping the source server. This adds coverage for the case where a
source server is still running, checking for port patterns and a success
case where the old server still runs.
The chdir() required for VPATH builds needs to be moved slightly
earlier, to adapt to the generation of the logs.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://postgr.es/m/apU4/hmRv/4gv20W@bdtpg
src/bin/pg_upgrade/t/002_pg_upgrade.pl | 46 ++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 0a4121fdc4d..a0bc51f3292 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -475,6 +475,47 @@ if (defined($ENV{oldinstall}))
}
}
+# In a VPATH build, we'll be started in the source directory, but we want
+# to run pg_upgrade in the build directory so that any files generated finish
+# in it, like delete_old_cluster.{sh,bat}.
+chdir ${PostgreSQL::Test::Utils::tmp_check};
+
+my @live_check_command = (
+ 'pg_upgrade', '--no-sync',
+ '--old-datadir' => $oldnode->data_dir,
+ '--new-datadir' => $newnode->data_dir,
+ '--old-bindir' => $oldbindir,
+ '--new-bindir' => $newbindir,
+ '--socketdir' => $newnode->host,
+ '--old-port' => $oldnode->port);
+
+# A live check must use different ports for the running old server and
+# the temporary new server.
+command_checks_all(
+ [
+ @live_check_command,
+ '--new-port' => $oldnode->port,
+ $mode, '--check',
+ ],
+ 1,
+ [
+ qr/When checking a live server, the old and new port numbers must be different\./
+ ],
+ [],
+ 'pg_upgrade --check with the same old and new ports');
+
+rmtree($newnode->data_dir . "/pg_upgrade_output.d");
+
+# Check the old cluster while it is running.
+command_like(
+ [
+ @live_check_command,
+ '--new-port' => $newnode->port,
+ $mode, '--check',
+ ],
+ qr/Performing Consistency Checks on Old Live Server/,
+ 'run of pg_upgrade --check with old instance running');
+
# Create an invalid database, will be deleted below
$oldnode->safe_psql(
'postgres', qq(
@@ -482,11 +523,6 @@ $oldnode->safe_psql(
UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid';
));
-# In a VPATH build, we'll be started in the source directory, but we want
-# to run pg_upgrade in the build directory so that any files generated finish
-# in it, like delete_old_cluster.{sh,bat}.
-chdir ${PostgreSQL::Test::Utils::tmp_check};
-
# Upgrade the instance.
$oldnode->stop;
[parent: 6fe9b62914bc]