Skip to content

Commit 331828b

Browse files
committed
Back-patch fixes to make TAP tests work on Windows.
This back-ports commit 13d856e and assorted followon patches into 9.4 and 9.5. 9.5 and HEAD are now substantially identical in all the files touched by this commit, except that 010_pg_basebackup.pl has a few more tests related to the new --slot option. 9.4 has many fewer TAP tests, but the test infrastructure files are substantially the same, with the exception that 9.4 lacks the single-tmp-install infrastructure introduced in 9.5 (commit dcae5fa). The primary motivation for this patch is to ensure that TAP test case fixes can be back-patched without hazards of the kind seen in commits 34557f5/06dd4b44f. In principle it should also make the world safe for running the TAP tests in the buildfarm in these branches; although we might want to think about back-porting dcae5fa to 9.4 if we're going to do that for real, because the TAP tests are quite disk space hungry without it. Michael Paquier did the back-porting work; original patches were by him and assorted other people.
1 parent a408bd5 commit 331828b

File tree

11 files changed

+300
-113
lines changed

11 files changed

+300
-113
lines changed

doc/src/sgml/install-windows.sgml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ $ENV{CONFIG}="Debug";
439439
<userinput>vcregress modulescheck</userinput>
440440
<userinput>vcregress ecpgcheck</userinput>
441441
<userinput>vcregress isolationcheck</userinput>
442+
<userinput>vcregress tapcheck</userinput>
442443
<userinput>vcregress upgradecheck</userinput>
443444
</screen>
444445

@@ -451,6 +452,29 @@ $ENV{CONFIG}="Debug";
451452
For more information about the regression tests, see
452453
<xref linkend="regress">.
453454
</para>
455+
456+
<para>
457+
Running the TAP regression tests, with "vcregress tapcheck", requires an
458+
additional Perl module to be installed:
459+
<variablelist>
460+
<varlistentry>
461+
<term><productname>IPC::Run</productname></term>
462+
<listitem><para>
463+
As of this writing, <literal>IPC::Run</> is not included in the
464+
ActiveState Perl installation, nor in the ActiveState Perl Package
465+
Manager (PPM) library. To install, download the
466+
<filename>IPC-Run-&lt;version&gt;.tar.gz</> source archive from CPAN,
467+
at <ulink url="http://search.cpan.org/dist/IPC-Run/"></>, and
468+
uncompress. Edit the <filename>buildenv.pl</> file, and add a PERL5LIB
469+
variable to point to the <filename>lib</> subdirectory from the
470+
extracted archive. For example:
471+
<programlisting>
472+
$ENV{PERL5LIB}=$ENV{PERL5LIB} . ';c:\IPC-Run-0.94\lib';
473+
</programlisting>
474+
</para></listitem>
475+
</varlistentry>
476+
</variablelist>
477+
</para>
454478
</sect2>
455479

456480
<sect2>

src/Makefile.global.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,12 @@ ifeq ($(enable_tap_tests),yes)
352352

353353
define prove_installcheck
354354
rm -rf $(CURDIR)/tmp_check/log
355-
cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
355+
cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
356356
endef
357357

358358
define prove_check
359359
rm -rf $(CURDIR)/tmp_check/log
360-
cd $(srcdir) && TESTDIR='$(CURDIR)' $(with_temp_install) PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
360+
cd $(srcdir) && TESTDIR='$(CURDIR)' $(with_temp_install) PGPORT='6$(DEF_PGPORT)' PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
361361
endef
362362

363363
else
Lines changed: 98 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use strict;
22
use warnings;
33
use Cwd;
4+
use Config;
45
use TestLib;
5-
use Test::More tests => 35;
6+
use Test::More tests => 46;
67

78
program_help_ok('pg_basebackup');
89
program_version_ok('pg_basebackup');
@@ -25,18 +26,15 @@
2526
close BADCHARS;
2627
}
2728

28-
open HBA, ">>$tempdir/pgdata/pg_hba.conf";
29-
print HBA "local replication all trust\n";
30-
print HBA "host replication all 127.0.0.1/32 trust\n";
31-
print HBA "host replication all ::1/128 trust\n";
32-
close HBA;
29+
configure_hba_for_replication "$tempdir/pgdata";
3330
system_or_bail 'pg_ctl', '-D', "$tempdir/pgdata", 'reload';
3431

3532
command_fails(
3633
[ 'pg_basebackup', '-D', "$tempdir/backup" ],
3734
'pg_basebackup fails because of WAL configuration');
3835

3936
open CONF, ">>$tempdir/pgdata/postgresql.conf";
37+
print CONF "max_replication_slots = 10\n";
4038
print CONF "max_wal_senders = 10\n";
4139
print CONF "wal_level = archive\n";
4240
close CONF;
@@ -46,6 +44,10 @@
4644
'pg_basebackup runs');
4745
ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
4846

47+
is_deeply([sort(slurp_dir("$tempdir/backup/pg_xlog/"))],
48+
[sort qw(. .. archive_status)],
49+
'no WAL files copied');
50+
4951
command_ok(
5052
[ 'pg_basebackup', '-D', "$tempdir/backup2", '--xlogdir',
5153
"$tempdir/xlog2" ],
@@ -57,61 +59,6 @@
5759
'tar format');
5860
ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
5961

60-
my $superlongname = "superlongname_" . ("x" x 100);
61-
62-
system_or_bail 'touch', "$tempdir/pgdata/$superlongname";
63-
command_fails([ 'pg_basebackup', '-D', "$tempdir/tarbackup_l1", '-Ft' ],
64-
'pg_basebackup tar with long name fails');
65-
unlink "$tempdir/pgdata/$superlongname";
66-
67-
# Create a temporary directory in the system location and symlink it
68-
# to our physical temp location. That way we can use shorter names
69-
# for the tablespace directories, which hopefully won't run afoul of
70-
# the 99 character length limit.
71-
my $shorter_tempdir = tempdir_short . "/tempdir";
72-
symlink "$tempdir", $shorter_tempdir;
73-
74-
mkdir "$tempdir/tblspc1";
75-
psql 'postgres',
76-
"CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';";
77-
psql 'postgres', "CREATE TABLE test1 (a int) TABLESPACE tblspc1;";
78-
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup2", '-Ft' ],
79-
'tar format with tablespaces');
80-
ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created');
81-
my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar";
82-
is(scalar(@tblspc_tars), 1, 'one tablespace tar was created');
83-
84-
command_fails(
85-
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ],
86-
'plain format with tablespaces fails without tablespace mapping');
87-
88-
command_ok(
89-
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp',
90-
"-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ],
91-
'plain format with tablespaces succeeds with tablespace mapping');
92-
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
93-
opendir(my $dh, "$tempdir/pgdata/pg_tblspc") or die;
94-
ok( ( grep {
95-
-l "$tempdir/backup1/pg_tblspc/$_"
96-
and readlink "$tempdir/backup1/pg_tblspc/$_" eq
97-
"$tempdir/tbackup/tblspc1"
98-
} readdir($dh)),
99-
"tablespace symlink was updated");
100-
closedir $dh;
101-
102-
mkdir "$tempdir/tbl=spc2";
103-
psql 'postgres', "DROP TABLE test1;";
104-
psql 'postgres', "DROP TABLESPACE tblspc1;";
105-
psql 'postgres',
106-
"CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';";
107-
command_ok(
108-
[ 'pg_basebackup', '-D', "$tempdir/backup3", '-Fp',
109-
"-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ],
110-
'mapping tablespace with = sign in path');
111-
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
112-
113-
psql 'postgres', "DROP TABLESPACE tblspc2;";
114-
11562
command_fails(
11663
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ],
11764
'-T with empty old directory fails');
@@ -132,9 +79,93 @@
13279
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo" ],
13380
'-T with invalid format fails');
13481

135-
mkdir "$tempdir/$superlongname";
136-
psql 'postgres',
137-
"CREATE TABLESPACE tblspc3 LOCATION '$tempdir/$superlongname';";
138-
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup_l3", '-Ft' ],
139-
'pg_basebackup tar with long symlink target');
140-
psql 'postgres', "DROP TABLESPACE tblspc3;";
82+
# Tar format doesn't support filenames longer than 100 bytes.
83+
my $superlongname = "superlongname_" . ("x" x 100);
84+
my $superlongpath = "$tempdir/pgdata/$superlongname";
85+
86+
open FILE, ">$superlongpath" or die "unable to create file $superlongpath";
87+
close FILE;
88+
command_fails([ 'pg_basebackup', '-D', "$tempdir/tarbackup_l1", '-Ft' ],
89+
'pg_basebackup tar with long name fails');
90+
unlink "$tempdir/pgdata/$superlongname";
91+
92+
# The following tests test symlinks. Windows doesn't have symlinks, so
93+
# skip on Windows.
94+
SKIP: {
95+
skip "symlinks not supported on Windows", 10 if ($windows_os);
96+
97+
# Create a temporary directory in the system location and symlink it
98+
# to our physical temp location. That way we can use shorter names
99+
# for the tablespace directories, which hopefully won't run afoul of
100+
# the 99 character length limit.
101+
my $shorter_tempdir = tempdir_short . "/tempdir";
102+
symlink "$tempdir", $shorter_tempdir;
103+
104+
mkdir "$tempdir/tblspc1";
105+
psql 'postgres',
106+
"CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';";
107+
psql 'postgres', "CREATE TABLE test1 (a int) TABLESPACE tblspc1;";
108+
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup2", '-Ft' ],
109+
'tar format with tablespaces');
110+
ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created');
111+
my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar";
112+
is(scalar(@tblspc_tars), 1, 'one tablespace tar was created');
113+
114+
command_fails(
115+
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ],
116+
'plain format with tablespaces fails without tablespace mapping');
117+
118+
command_ok(
119+
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp',
120+
"-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ],
121+
'plain format with tablespaces succeeds with tablespace mapping');
122+
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
123+
opendir(my $dh, "$tempdir/pgdata/pg_tblspc") or die;
124+
ok( ( grep {
125+
-l "$tempdir/backup1/pg_tblspc/$_"
126+
and readlink "$tempdir/backup1/pg_tblspc/$_" eq
127+
"$tempdir/tbackup/tblspc1"
128+
} readdir($dh)),
129+
"tablespace symlink was updated");
130+
closedir $dh;
131+
132+
mkdir "$tempdir/tbl=spc2";
133+
psql 'postgres', "DROP TABLE test1;";
134+
psql 'postgres', "DROP TABLESPACE tblspc1;";
135+
psql 'postgres',
136+
"CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';";
137+
command_ok(
138+
[ 'pg_basebackup', '-D', "$tempdir/backup3", '-Fp',
139+
"-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ],
140+
'mapping tablespace with = sign in path');
141+
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
142+
psql 'postgres', "DROP TABLESPACE tblspc2;";
143+
144+
mkdir "$tempdir/$superlongname";
145+
psql 'postgres',
146+
"CREATE TABLESPACE tblspc3 LOCATION '$tempdir/$superlongname';";
147+
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup_l3", '-Ft' ],
148+
'pg_basebackup tar with long symlink target');
149+
psql 'postgres', "DROP TABLESPACE tblspc3;";
150+
}
151+
152+
command_ok([ 'pg_basebackup', '-D', "$tempdir/backupR", '-R' ],
153+
'pg_basebackup -R runs');
154+
ok(-f "$tempdir/backupR/recovery.conf", 'recovery.conf was created');
155+
my $recovery_conf = slurp_file "$tempdir/backupR/recovery.conf";
156+
# using a character class for the final "'" here works around an apparent
157+
# bug in several version of the Msys DTK perl
158+
like($recovery_conf, qr/^standby_mode = 'on[']$/m, 'recovery.conf sets standby_mode');
159+
like($recovery_conf, qr/^primary_conninfo = '.*port=$ENV{PGPORT}.*'$/m, 'recovery.conf sets primary_conninfo');
160+
161+
command_ok([ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ],
162+
'pg_basebackup -X fetch runs');
163+
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), 'WAL files copied');
164+
command_ok([ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ],
165+
'pg_basebackup -X stream runs');
166+
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), 'WAL files copied');
167+
168+
command_fails([ 'pg_basebackup', '-D', "$tempdir/fail", '-S', 'slot1' ],
169+
'pg_basebackup with replication slot fails without -X stream');
170+
command_fails([ 'pg_basebackup', '-D', "$tempdir/backupxs_sl_fail", '-X', 'stream', '-S', 'slot1' ],
171+
'pg_basebackup fails with nonexistent replication slot');

src/bin/pg_ctl/t/001_start_stop.pl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use strict;
22
use warnings;
3+
use Config;
34
use TestLib;
45
use Test::More tests => 17;
56

@@ -16,13 +17,20 @@
1617
command_ok([ 'pg_ctl', 'initdb', '-D', "$tempdir/data", '-o', '-N' ],
1718
'pg_ctl initdb');
1819
command_ok(
19-
[ "$ENV{top_builddir}/src/test/regress/pg_regress", '--config-auth',
20+
[ $ENV{PG_REGRESS}, '--config-auth',
2021
"$tempdir/data" ],
2122
'configure authentication');
2223
open CONF, ">>$tempdir/data/postgresql.conf";
23-
print CONF "listen_addresses = ''\n";
24-
print CONF "unix_socket_directories = '$tempdir_short'\n";
2524
print CONF "fsync = off\n";
25+
if (! $windows_os)
26+
{
27+
print CONF "listen_addresses = ''\n";
28+
print CONF "unix_socket_directories = '$tempdir_short'\n";
29+
}
30+
else
31+
{
32+
print CONF "listen_addresses = '127.0.0.1'\n";
33+
}
2634
close CONF;
2735
command_ok([ 'pg_ctl', 'start', '-D', "$tempdir/data", '-w' ],
2836
'pg_ctl start -w');

src/bin/pg_ctl/t/002_status.pl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
4, 'pg_ctl status with nonexistent directory');
1111

1212
standard_initdb "$tempdir/data";
13-
open CONF, ">>$tempdir/data/postgresql.conf";
14-
print CONF "listen_addresses = ''\n";
15-
print CONF "unix_socket_directories = '$tempdir_short'\n";
16-
close CONF;
1713

1814
command_exit_is([ 'pg_ctl', 'status', '-D', "$tempdir/data" ],
1915
3, 'pg_ctl status with server not running');

0 commit comments

Comments
 (0)