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 <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
This commit is contained in:
Peter Eisentraut 2022-12-16 17:49:59 +01:00
parent 746915c686
commit b059a2409f
2 changed files with 23 additions and 3 deletions

View 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
-------

View 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",