Skip to content

Commit b059a24

Browse files
committed
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
1 parent 746915c commit b059a24

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/bin/pg_upgrade/TESTING

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ THE SHORT VERSION
33

44
On non-Windows machines, you can execute the testing process
55
described below by running the following command in this directory:
6+
67
make check
78

89
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)
1718
export oldinstall=...otherversion/ (old version's install base path)
1819

1920
Finally, the tests can be done by running
21+
2022
make check
2123

24+
You can also test the different transfer modes (--copy, --link,
25+
--clone) by setting the environment variable PG_TEST_PG_UPGRADE_MODE
26+
to the respective command-line option, like
27+
28+
make check PG_TEST_PG_UPGRADE_MODE=--link
29+
30+
The default is --copy. Note that the other modes are not supported on
31+
all operating systems.
32+
2233
DETAILS
2334
-------
2435

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use PostgreSQL::Test::Utils;
1313
use Test::More;
1414

15+
# Can be changed to test the other modes.
16+
my $mode = $ENV{PG_TEST_PG_UPGRADE_MODE} || '--copy';
17+
1518
# Generate a database with a name made of a range of ASCII characters.
1619
sub generate_db
1720
{
@@ -75,6 +78,8 @@ sub filter_dump
7578
my $dump1_file = "$tempdir/dump1.sql";
7679
my $dump2_file = "$tempdir/dump2.sql";
7780

81+
note "testing using transfer mode $mode";
82+
7883
# Initialize node to upgrade
7984
my $oldnode =
8085
PostgreSQL::Test::Cluster->new('old_node',
@@ -128,6 +133,7 @@ sub filter_dump
128133
# --inputdir points to the path of the input files.
129134
my $inputdir = "$srcdir/src/test/regress";
130135

136+
note 'running regression tests in old instance';
131137
my $rc =
132138
system($ENV{PG_REGRESS}
133139
. " $extra_opts "
@@ -256,7 +262,8 @@ sub filter_dump
256262
'-s', $newnode->host,
257263
'-p', $oldnode->port,
258264
'-P', $newnode->port,
259-
'--check'
265+
$mode,
266+
'--check',
260267
],
261268
'run of pg_upgrade --check for new instance with incorrect binary path');
262269
ok(-d $newnode->data_dir . "/pg_upgrade_output.d",
@@ -270,7 +277,8 @@ sub filter_dump
270277
'-D', $newnode->data_dir, '-b', $oldbindir,
271278
'-B', $newbindir, '-s', $newnode->host,
272279
'-p', $oldnode->port, '-P', $newnode->port,
273-
'--check'
280+
$mode,
281+
'--check',
274282
],
275283
'run of pg_upgrade --check for new instance');
276284
ok(!-d $newnode->data_dir . "/pg_upgrade_output.d",
@@ -282,7 +290,8 @@ sub filter_dump
282290
'pg_upgrade', '--no-sync', '-d', $oldnode->data_dir,
283291
'-D', $newnode->data_dir, '-b', $oldbindir,
284292
'-B', $newbindir, '-s', $newnode->host,
285-
'-p', $oldnode->port, '-P', $newnode->port
293+
'-p', $oldnode->port, '-P', $newnode->port,
294+
$mode,
286295
],
287296
'run of pg_upgrade for new instance');
288297
ok( !-d $newnode->data_dir . "/pg_upgrade_output.d",

0 commit comments

Comments
 (0)