src/bin/pg_upgrade/test.sh runs installcheck, which writes to files in
src/test/regress.  This has at least two disadvantages when check-world runs
both this test suite and the "make check" suite:

1. The suite finishing second will overwrite the other's regression.{out,diffs}.
2. If these suites run a given test file in parallel (possible with "make -j
   check-world"), they simultaneously edit a file in src/test/regress/results.
   This can cause reporting of spurious failures.  On my system, the symptom
   is a regression.diffs indicating that the .out file contained ranges of NUL
   bytes (holes) and/or lacked expected lines.

A disadvantage of any change here is that it degrades buildfarm reports, which
recover slowly as owners upgrade to a fixed buildfarm release.  This will be
similar to the introduction of --outputdir=output_iso.  On non-upgraded
animals, pg_upgradeCheck failures will omit regression.diffs.

I think the right fix, attached, is to use "pg_regress --outputdir" to
redirect these files to src/bin/pg_upgrade/tmp_check/regress.  I chose that
particular path because it will still fit naturally if we ever rewrite test.sh
using src/test/perl.  I'm recommending that the buildfarm capture[1] files
matching src/bin/pg_upgrade/tmp_check/*/*.diffs, which will work even if we
make this test suite run installcheck more than once.  This revealed a few
places where tests assume @abs_builddir@ is getcwd(), which I fixed.

Thanks,
nm

[1] 
https://github.com/PGBuildFarm/client-code/blob/REL_9/PGBuild/Modules/TestUpgrade.pm#L126
diff --git a/GNUmakefile.in b/GNUmakefile.in
index 563c83b..f4e31a7 100644
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 956fd27..bbeea17 100644
diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh
index 1d3272d..7bc7fca 100644
--- a/src/bin/pg_upgrade/test.sh
+++ b/src/bin/pg_upgrade/test.sh
@@ -110,6 +110,18 @@ PGDATA="${BASE_PGDATA}.old"
 export PGDATA
 rm -rf "$BASE_PGDATA" "$PGDATA"
 
+# Send installcheck outputs to a private directory.  This avoids conflict when
+# check-world runs pg_upgrade check concurrently with src/test/regress check.
+# To retrieve interesting files after a run, use pattern tmp_check/*/*.diffs.
+outputdir="$temp_root/regress"
+EXTRA_REGRESS_OPTS="$EXTRA_REGRESS_OPTS --outputdir=$outputdir"
+export EXTRA_REGRESS_OPTS
+rm -rf "$outputdir"
+mkdir "$outputdir"
+mkdir "$outputdir"/sql
+mkdir "$outputdir"/expected
+mkdir "$outputdir"/testtablespace
+
 logdir=`pwd`/log
 rm -rf "$logdir"
 mkdir "$logdir"
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 7e7c54f..d214cb9 100644
diff --git a/src/test/regress/input/largeobject.source 
b/src/test/regress/input/largeobject.source
index b7a9d05..7e45b11 100644
--- a/src/test/regress/input/largeobject.source
+++ b/src/test/regress/input/largeobject.source
@@ -203,12 +203,12 @@ END;
 
 SELECT lo_export(loid, '@abs_builddir@/results/lotest.txt') FROM 
lotest_stash_values;
 
-\lo_import 'results/lotest.txt'
+\lo_import '@abs_builddir@/results/lotest.txt'
 
 \set newloid :LASTOID
 
 -- just make sure \lo_export does not barf
-\lo_export :newloid 'results/lotest2.txt'
+\lo_export :newloid '@abs_builddir@/results/lotest2.txt'
 
 -- This is a hack to test that export/import are reversible
 -- This uses knowledge about the inner workings of large object mechanism
@@ -223,7 +223,7 @@ TRUNCATE lotest_stash_values;
 
 \lo_unlink :newloid
 
-\lo_import 'results/lotest.txt'
+\lo_import '@abs_builddir@/results/lotest.txt'
 
 \set newloid_1 :LASTOID
 
diff --git a/src/test/regress/output/largeobject.source 
b/src/test/regress/output/largeobject.source
index e29f542..761d7ff 100644
--- a/src/test/regress/output/largeobject.source
+++ b/src/test/regress/output/largeobject.source
@@ -385,10 +385,10 @@ SELECT lo_export(loid, 
'@abs_builddir@/results/lotest.txt') FROM lotest_stash_va
          1
 (1 row)
 
-\lo_import 'results/lotest.txt'
+\lo_import '@abs_builddir@/results/lotest.txt'
 \set newloid :LASTOID
 -- just make sure \lo_export does not barf
-\lo_export :newloid 'results/lotest2.txt'
+\lo_export :newloid '@abs_builddir@/results/lotest2.txt'
 -- This is a hack to test that export/import are reversible
 -- This uses knowledge about the inner workings of large object mechanism
 -- which should not be used outside it.  This makes it a HACK
@@ -407,7 +407,7 @@ SELECT lo_unlink(loid) FROM lotest_stash_values;
 
 TRUNCATE lotest_stash_values;
 \lo_unlink :newloid
-\lo_import 'results/lotest.txt'
+\lo_import '@abs_builddir@/results/lotest.txt'
 \set newloid_1 :LASTOID
 SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2
 \gset
diff --git a/src/test/regress/output/largeobject_1.source 
b/src/test/regress/output/largeobject_1.source
index 6fd8cbe..7de3e7e 100644
--- a/src/test/regress/output/largeobject_1.source
+++ b/src/test/regress/output/largeobject_1.source
@@ -385,10 +385,10 @@ SELECT lo_export(loid, 
'@abs_builddir@/results/lotest.txt') FROM lotest_stash_va
          1
 (1 row)
 
-\lo_import 'results/lotest.txt'
+\lo_import '@abs_builddir@/results/lotest.txt'
 \set newloid :LASTOID
 -- just make sure \lo_export does not barf
-\lo_export :newloid 'results/lotest2.txt'
+\lo_export :newloid '@abs_builddir@/results/lotest2.txt'
 -- This is a hack to test that export/import are reversible
 -- This uses knowledge about the inner workings of large object mechanism
 -- which should not be used outside it.  This makes it a HACK
@@ -407,7 +407,7 @@ SELECT lo_unlink(loid) FROM lotest_stash_values;
 
 TRUNCATE lotest_stash_values;
 \lo_unlink :newloid
-\lo_import 'results/lotest.txt'
+\lo_import '@abs_builddir@/results/lotest.txt'
 \set newloid_1 :LASTOID
 SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2
 \gset
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 4018313..a93e207 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -102,6 +102,13 @@ exit 0;
 sub installcheck
 {
        my $schedule = shift || 'serial';
+       installcheck_internal $schedule;
+       return;
+}
+
+sub installcheck_internal
+{
+       my ($schedule, @EXTRA_REGRESS_OPTS) = @_;
        my @args = (
                "../../../$Config/pg_regress/pg_regress",
                "--dlpath=.",
@@ -111,6 +118,7 @@ sub installcheck
                "--encoding=SQL_ASCII",
                "--no-locale");
        push(@args, $maxconn) if $maxconn;
+       push(@args, @EXTRA_REGRESS_OPTS);
        system(@args);
        my $status = $? >> 8;
        exit $status if $status;
@@ -557,6 +565,14 @@ sub upgradecheck
        $ENV{PATH} = "$bindir;$ENV{PATH}";
        my $data = "$tmp_root/data";
        $ENV{PGDATA} = "$data.old";
+       my $outputdir          = "$tmp_root/regress";
+       my @EXTRA_REGRESS_OPTS = ("--outputdir=$outputdir");
+       rmtree("$outputdir");
+       mkdir "$outputdir"                || die $!;
+       mkdir "$outputdir/sql"            || die $!;
+       mkdir "$outputdir/expected"       || die $!;
+       mkdir "$outputdir/testtablespace" || die $!;
+
        my $logdir = "$topdir/src/bin/pg_upgrade/log";
        (mkdir $logdir || die $!) unless -d $logdir;
        print "\nRunning initdb on old cluster\n\n";
@@ -571,7 +587,7 @@ sub upgradecheck
        generate_db('',       91, 127, '');
 
        print "\nSetting up data for upgrading\n\n";
-       installcheck('parallel');
+       installcheck_internal('parallel', @EXTRA_REGRESS_OPTS);
 
        # now we can chdir into the source dir
        chdir "$topdir/src/bin/pg_upgrade";

Reply via email to