Skip to content

Commit 8bc496c

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 a6c4c07 commit 8bc496c

File tree

9 files changed

+239
-76
lines changed

9 files changed

+239
-76
lines changed

doc/src/sgml/install-windows.sgml

+24
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ $ENV{CONFIG}="Debug";
438438
<userinput>vcregress contribcheck</userinput>
439439
<userinput>vcregress ecpgcheck</userinput>
440440
<userinput>vcregress isolationcheck</userinput>
441+
<userinput>vcregress tapcheck</userinput>
441442
<userinput>vcregress upgradecheck</userinput>
442443
</screen>
443444

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

455479
<sect2>

src/Makefile.global.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@ ifeq ($(enable_tap_tests),yes)
334334

335335
define prove_installcheck
336336
rm -rf $(CURDIR)/tmp_check/log
337-
cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
337+
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
338338
endef
339339

340340
define prove_check
341341
rm -rf $(CURDIR)/tmp_check/log
342342
$(MKDIR_P) tmp_check/log
343343
$(MAKE) -C $(top_builddir) DESTDIR='$(CURDIR)'/tmp_check/install install >'$(CURDIR)'/tmp_check/log/install.log 2>&1
344-
cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(CURDIR)/tmp_check/install$(bindir):$$PATH" $(call add_to_path,$(ld_library_path_var),$(CURDIR)/tmp_check/install$(libdir)) top_builddir='$(CURDIR)/$(top_builddir)' PGPORT='6$(DEF_PGPORT)' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
344+
cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(CURDIR)/tmp_check/install$(bindir):$$PATH" $(call add_to_path,$(ld_library_path_var),$(CURDIR)/tmp_check/install$(libdir)) top_builddir='$(CURDIR)/$(top_builddir)' PGPORT='6$(DEF_PGPORT)' PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) t/*.pl
345345
endef
346346

347347
else

src/bin/pg_basebackup/t/010_pg_basebackup.pl

+55-53
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
close BADCHARS;
2626
}
2727

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;
28+
configure_hba_for_replication "$tempdir/pgdata";
3329
system_or_bail 'pg_ctl', '-D', "$tempdir/pgdata", 'reload';
3430

3531
command_fails(
@@ -57,54 +53,60 @@
5753
'tar format');
5854
ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
5955

60-
# Create a temporary directory in the system location and symlink it
61-
# to our physical temp location. That way we can use shorter names
62-
# for the tablespace directories, which hopefully won't run afoul of
63-
# the 99 character length limit.
64-
my $shorter_tempdir = tempdir_short . "/tempdir";
65-
symlink "$tempdir", $shorter_tempdir;
66-
67-
mkdir "$tempdir/tblspc1";
68-
psql 'postgres', "CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';";
69-
psql 'postgres', "CREATE TABLE test1 (a int) TABLESPACE tblspc1;";
70-
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup2", '-Ft' ],
71-
'tar format with tablespaces');
72-
ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created');
73-
my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar";
74-
is(scalar(@tblspc_tars), 1, 'one tablespace tar was created');
75-
76-
command_fails(
77-
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ],
78-
'plain format with tablespaces fails without tablespace mapping');
79-
80-
command_ok(
81-
[ 'pg_basebackup', '-D',
82-
"$tempdir/backup1", '-Fp',
83-
"-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ],
84-
'plain format with tablespaces succeeds with tablespace mapping');
85-
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
86-
opendir(my $dh, "$tempdir/pgdata/pg_tblspc") or die;
87-
ok( ( grep
88-
{
89-
-l "$tempdir/backup1/pg_tblspc/$_"
90-
and readlink "$tempdir/backup1/pg_tblspc/$_" eq
91-
"$tempdir/tbackup/tblspc1"
92-
} readdir($dh)),
93-
"tablespace symlink was updated");
94-
closedir $dh;
95-
96-
mkdir "$tempdir/tbl=spc2";
97-
psql 'postgres', "DROP TABLE test1;";
98-
psql 'postgres', "DROP TABLESPACE tblspc1;";
99-
psql 'postgres', "CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';";
100-
command_ok(
101-
[ 'pg_basebackup', '-D',
102-
"$tempdir/backup3", '-Fp',
103-
"-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ],
104-
'mapping tablespace with = sign in path');
105-
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
106-
107-
psql 'postgres', "DROP TABLESPACE tblspc2;";
56+
# The following tests test symlinks. Windows doesn't have symlinks, so
57+
# skip on Windows.
58+
SKIP: {
59+
# Create a temporary directory in the system location and symlink it
60+
# to our physical temp location. That way we can use shorter names
61+
# for the tablespace directories, which hopefully won't run afoul of
62+
# the 99 character length limit.
63+
skip "symlinks not supported on Windows", 9 if ($windows_os);
64+
65+
my $shorter_tempdir = tempdir_short . "/tempdir";
66+
symlink "$tempdir", $shorter_tempdir;
67+
68+
mkdir "$tempdir/tblspc1";
69+
psql 'postgres', "CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';";
70+
psql 'postgres', "CREATE TABLE test1 (a int) TABLESPACE tblspc1;";
71+
command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup2", '-Ft' ],
72+
'tar format with tablespaces');
73+
ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created');
74+
my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar";
75+
is(scalar(@tblspc_tars), 1, 'one tablespace tar was created');
76+
77+
command_fails(
78+
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ],
79+
'plain format with tablespaces fails without tablespace mapping');
80+
81+
command_ok(
82+
[ 'pg_basebackup', '-D',
83+
"$tempdir/backup1", '-Fp',
84+
"-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ],
85+
'plain format with tablespaces succeeds with tablespace mapping');
86+
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
87+
opendir(my $dh, "$tempdir/pgdata/pg_tblspc") or die;
88+
ok( ( grep
89+
{
90+
-l "$tempdir/backup1/pg_tblspc/$_"
91+
and readlink "$tempdir/backup1/pg_tblspc/$_" eq
92+
"$tempdir/tbackup/tblspc1"
93+
} readdir($dh)),
94+
"tablespace symlink was updated");
95+
closedir $dh;
96+
97+
mkdir "$tempdir/tbl=spc2";
98+
psql 'postgres', "DROP TABLE test1;";
99+
psql 'postgres', "DROP TABLESPACE tblspc1;";
100+
psql 'postgres', "CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';";
101+
command_ok(
102+
[ 'pg_basebackup', '-D',
103+
"$tempdir/backup3", '-Fp',
104+
"-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ],
105+
'mapping tablespace with = sign in path');
106+
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
107+
108+
psql 'postgres', "DROP TABLESPACE tblspc2;";
109+
}
108110

109111
command_fails(
110112
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ],

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

+12-3
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 => 16;
56

@@ -12,12 +13,20 @@
1213

1314
command_ok([ 'pg_ctl', 'initdb', '-D', "$tempdir/data" ], 'pg_ctl initdb');
1415
command_ok(
15-
[ "$ENV{top_builddir}/src/test/regress/pg_regress", '--config-auth',
16+
[ $ENV{PG_REGRESS}, '--config-auth',
1617
"$tempdir/data" ],
1718
'configure authentication');
1819
open CONF, ">>$tempdir/data/postgresql.conf";
19-
print CONF "listen_addresses = ''\n";
20-
print CONF "unix_socket_directories = '$tempdir_short'\n";
20+
print CONF "fsync = off\n";
21+
if (! $windows_os)
22+
{
23+
print CONF "listen_addresses = ''\n";
24+
print CONF "unix_socket_directories = '$tempdir_short'\n";
25+
}
26+
else
27+
{
28+
print CONF "listen_addresses = '127.0.0.1'\n";
29+
}
2130
close CONF;
2231
command_ok([ 'pg_ctl', 'start', '-D', "$tempdir/data", '-w' ],
2332
'pg_ctl start -w');

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

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
my $tempdir_short = TestLib::tempdir_short;
88

99
standard_initdb "$tempdir/data";
10-
open CONF, ">>$tempdir/data/postgresql.conf";
11-
print CONF "listen_addresses = ''\n";
12-
print CONF "unix_socket_directories = '$tempdir_short'\n";
13-
close CONF;
1410

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

src/test/perl/SimpleTee.pm

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ sub PRINT {
2020
my $ok = 1;
2121
for my $fh (@$self) {
2222
print $fh @_ or $ok = 0;
23+
$fh->flush or $ok = 0;
2324
}
2425
return $ok;
2526
}

0 commit comments

Comments
 (0)