summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2022-12-16 16:49:59 +0000
committerPeter Eisentraut2022-12-16 17:32:02 +0000
commitb059a2409faf5833b3ba7792e247d6466c9e8090 (patch)
tree4842c302c791dce73cac1ebba9612391e0e77d4e
parent746915c6866953506379e996ce5198bc9e9e5b94 (diff)
pg_upgrade: Make testing different transfer modes easier
The environment variable PG_TEST_PG_UPGRADE_MODE can be set to override the default transfer mode for the pg_upgrade tests. (Automatically running the pg_upgrade tests for all supported modes would be too slow.) Reviewed-by: Daniel Gustafsson <[email protected]> Reviewed-by: Kyotaro Horiguchi <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/50a97009-8ff9-ca4d-a0f6-6086a6775a5b%40enterprisedb.com
-rw-r--r--src/bin/pg_upgrade/TESTING11
-rw-r--r--src/bin/pg_upgrade/t/002_pg_upgrade.pl15
2 files changed, 23 insertions, 3 deletions
diff --git a/src/bin/pg_upgrade/TESTING b/src/bin/pg_upgrade/TESTING
index 200ce9d92b9..127dc30bbb3 100644
--- a/src/bin/pg_upgrade/TESTING
+++ b/src/bin/pg_upgrade/TESTING
@@ -3,6 +3,7 @@ THE SHORT VERSION
On non-Windows machines, you can execute the testing process
described below by running the following command in this directory:
+
make check
This will run the TAP tests to run pg_upgrade, performing an upgrade
@@ -17,8 +18,18 @@ export olddump=...somewhere/dump.sql (old version's dump)
export oldinstall=...otherversion/ (old version's install base path)
Finally, the tests can be done by running
+
make check
+You can also test the different transfer modes (--copy, --link,
+--clone) by setting the environment variable PG_TEST_PG_UPGRADE_MODE
+to the respective command-line option, like
+
+ make check PG_TEST_PG_UPGRADE_MODE=--link
+
+The default is --copy. Note that the other modes are not supported on
+all operating systems.
+
DETAILS
-------
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index add6ea9c343..4cc14693060 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -12,6 +12,9 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
+# Can be changed to test the other modes.
+my $mode = $ENV{PG_TEST_PG_UPGRADE_MODE} || '--copy';
+
# Generate a database with a name made of a range of ASCII characters.
sub generate_db
{
@@ -75,6 +78,8 @@ my $tempdir = PostgreSQL::Test::Utils::tempdir;
my $dump1_file = "$tempdir/dump1.sql";
my $dump2_file = "$tempdir/dump2.sql";
+note "testing using transfer mode $mode";
+
# Initialize node to upgrade
my $oldnode =
PostgreSQL::Test::Cluster->new('old_node',
@@ -128,6 +133,7 @@ else
# --inputdir points to the path of the input files.
my $inputdir = "$srcdir/src/test/regress";
+ note 'running regression tests in old instance';
my $rc =
system($ENV{PG_REGRESS}
. " $extra_opts "
@@ -256,7 +262,8 @@ command_fails(
'-s', $newnode->host,
'-p', $oldnode->port,
'-P', $newnode->port,
- '--check'
+ $mode,
+ '--check',
],
'run of pg_upgrade --check for new instance with incorrect binary path');
ok(-d $newnode->data_dir . "/pg_upgrade_output.d",
@@ -270,7 +277,8 @@ command_ok(
'-D', $newnode->data_dir, '-b', $oldbindir,
'-B', $newbindir, '-s', $newnode->host,
'-p', $oldnode->port, '-P', $newnode->port,
- '--check'
+ $mode,
+ '--check',
],
'run of pg_upgrade --check for new instance');
ok(!-d $newnode->data_dir . "/pg_upgrade_output.d",
@@ -282,7 +290,8 @@ command_ok(
'pg_upgrade', '--no-sync', '-d', $oldnode->data_dir,
'-D', $newnode->data_dir, '-b', $oldbindir,
'-B', $newbindir, '-s', $newnode->host,
- '-p', $oldnode->port, '-P', $newnode->port
+ '-p', $oldnode->port, '-P', $newnode->port,
+ $mode,
],
'run of pg_upgrade for new instance');
ok( !-d $newnode->data_dir . "/pg_upgrade_output.d",