mirror of
https://github.com/postgres/postgres.git
synced 2026-04-21 22:28:15 -04:00
Use command_ok for pg_regress calls in 002_pg_upgrade and 027_stream_regress
Now that command_ok() captures and displays failure output, use it instead of system() plus manual diff-dumping in these two tests. This simplifies both scripts and produces consistent, truncated output on failure. Author: Jelte Fennema-Nio <postgres@jeltef.nl> Reviewed-by: Andrew Dunstan <andrew@dunslane.net> Reviewed-by: Corey Huinker <corey.huinker@gmail.com> Discussion: https://postgr.es/m/DFYFWM053WHS.10K8ZPJ605UFK@jeltef.nl
This commit is contained in:
parent
b8da9869b8
commit
bb6ae9707c
2 changed files with 28 additions and 65 deletions
|
|
@ -280,32 +280,20 @@ 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 "
|
||||
. "--dlpath=\"$dlpath\" "
|
||||
. "--bindir= "
|
||||
. "--host="
|
||||
. $oldnode->host . " "
|
||||
. "--port="
|
||||
. $oldnode->port . " "
|
||||
. "--schedule=$srcdir/src/test/regress/parallel_schedule "
|
||||
. "--max-concurrent-tests=20 "
|
||||
. "--inputdir=\"$inputdir\" "
|
||||
. "--outputdir=\"$outputdir\"");
|
||||
if ($rc != 0)
|
||||
{
|
||||
# Dump out the regression diffs file, if there is one
|
||||
my $diffs = "$outputdir/regression.diffs";
|
||||
if (-e $diffs)
|
||||
{
|
||||
print "=== dumping $diffs ===\n";
|
||||
print slurp_file($diffs);
|
||||
print "=== EOF ===\n";
|
||||
}
|
||||
}
|
||||
is($rc, 0, 'regression tests pass');
|
||||
command_ok(
|
||||
[
|
||||
$ENV{PG_REGRESS},
|
||||
split(' ', $extra_opts),
|
||||
"--dlpath=$dlpath",
|
||||
'--bindir=',
|
||||
'--host=' . $oldnode->host,
|
||||
'--port=' . $oldnode->port,
|
||||
"--schedule=$srcdir/src/test/regress/parallel_schedule",
|
||||
'--max-concurrent-tests=20',
|
||||
"--inputdir=$inputdir",
|
||||
"--outputdir=$outputdir"
|
||||
],
|
||||
'regression tests in old instance');
|
||||
}
|
||||
|
||||
# Initialize a new node for the upgrade.
|
||||
|
|
|
|||
|
|
@ -68,48 +68,23 @@ my $outputdir = $PostgreSQL::Test::Utils::tmp_check;
|
|||
|
||||
# Run the regression tests against the primary.
|
||||
my $extra_opts = $ENV{EXTRA_REGRESS_OPTS} || "";
|
||||
my $rc =
|
||||
system($ENV{PG_REGRESS}
|
||||
. " $extra_opts "
|
||||
. "--dlpath=\"$dlpath\" "
|
||||
. "--bindir= "
|
||||
. "--host="
|
||||
. $node_primary->host . " "
|
||||
. "--port="
|
||||
. $node_primary->port . " "
|
||||
. "--schedule=../regress/parallel_schedule "
|
||||
. "--max-concurrent-tests=20 "
|
||||
. "--inputdir=../regress "
|
||||
. "--outputdir=\"$outputdir\"");
|
||||
command_ok(
|
||||
[
|
||||
$ENV{PG_REGRESS},
|
||||
split(' ', $extra_opts),
|
||||
"--dlpath=$dlpath",
|
||||
'--bindir=',
|
||||
'--host=' . $node_primary->host,
|
||||
'--port=' . $node_primary->port,
|
||||
'--schedule=../regress/parallel_schedule',
|
||||
'--max-concurrent-tests=20',
|
||||
'--inputdir=../regress',
|
||||
"--outputdir=$outputdir"
|
||||
],
|
||||
'regression tests pass');
|
||||
|
||||
# Regression diffs are only meaningful if both the primary and the standby
|
||||
# are still alive after a regression test failure.
|
||||
my $primary_alive = $node_primary->is_alive;
|
||||
my $standby_alive = $node_standby_1->is_alive;
|
||||
if ($rc != 0 && $primary_alive && $standby_alive)
|
||||
{
|
||||
# Dump out the regression diffs file, if there is one
|
||||
my $diffs = "$outputdir/regression.diffs";
|
||||
if (-e $diffs)
|
||||
{
|
||||
# Dump portions of the diff file.
|
||||
my ($head, $tail) = read_head_tail($diffs);
|
||||
|
||||
diag("=== dumping $diffs (head) ===");
|
||||
foreach my $line (@$head)
|
||||
{
|
||||
diag($line);
|
||||
}
|
||||
|
||||
diag("=== dumping $diffs (tail) ===");
|
||||
foreach my $line (@$tail)
|
||||
{
|
||||
diag($line);
|
||||
}
|
||||
diag("=== EOF ===");
|
||||
}
|
||||
}
|
||||
is($rc, 0, 'regression tests pass');
|
||||
is($primary_alive, 1, 'primary alive after regression test run');
|
||||
is($standby_alive, 1, 'standby alive after regression test run');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue