pg_upgrade: Make testing different transfer modes easier
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 16 Dec 2022 16:49:59 +0000 (17:49 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 16 Dec 2022 17:32:02 +0000 (18:32 +0100)
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 <daniel@yesql.se>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/50a97009-8ff9-ca4d-a0f6-6086a6775a5b%40enterprisedb.com

src/bin/pg_upgrade/TESTING
src/bin/pg_upgrade/t/002_pg_upgrade.pl

index 200ce9d92b9661fd2159dc2b84756f2e3ce464e7..127dc30bbb3136fc5b2cf0dd3b60e22bfa1cb79d 100644 (file)
@@ -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
 -------
 
index add6ea9c34371da43cb12f506b217180d9cab111..4cc14693060e45b9a7907e8f7fee60f671d3d4b8 100644 (file)
@@ -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",