Skip to content

Commit 73db8f4

Browse files
committed
Improve handling and logging of TAP tests for pg_upgrade
This commit includes a set of improvements to help with the debugging of failures in these new TAP tests: - Instead of a plain diff command to compare the dumps generated, use File::Compare::compare for the same effect. diff is still used to provide more context in the event of an error. - Log the contents of regression.diffs if the pg_regress command fails. - Unify the format of the logs generated, getting inspiration from the style used in 027_stream_regress.pl. wrasse is the only buildfarm member that has reported a failure until now after the introduction of 322becb, complaining that the dumps generated do not match, and I am lacking information to understand what is going in this environment.
1 parent 322becb commit 73db8f4

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Cwd qw(abs_path getcwd);
66
use File::Basename qw(dirname);
7+
use File::Compare;
78

89
use PostgreSQL::Test::Cluster;
910
use PostgreSQL::Test::Utils;
@@ -111,8 +112,18 @@ sub generate_db
111112
$inputdir
112113
];
113114

114-
$oldnode->command_ok(@regress_command,
115-
'regression test run on old instance');
115+
my $rc = run_log(@regress_command);
116+
if ($rc != 0)
117+
{
118+
# Dump out the regression diffs file, if there is one
119+
my $diffs = "$outputdir/regression.diffs";
120+
if (-e $diffs)
121+
{
122+
print "=== dumping $diffs ===\n";
123+
print slurp_file($diffs);
124+
print "=== EOF ===\n";
125+
}
126+
}
116127
}
117128

118129
# Before dumping, get rid of objects not existing or not supported in later
@@ -214,11 +225,9 @@ sub generate_db
214225
{
215226
foreach my $log (glob("$log_path/*"))
216227
{
217-
note "###########################";
218-
note "Contents of log file $log";
219-
note "###########################";
220-
my $log_contents = slurp_file($log);
221-
print "$log_contents\n";
228+
note "=== contents of $log ===\n";
229+
print slurp_file($log);
230+
print "=== EOF ===\n";
222231
}
223232
}
224233

@@ -231,7 +240,20 @@ sub generate_db
231240
]);
232241

233242
# Compare the two dumps, there should be no differences.
234-
command_ok([ 'diff', '-q', "$tempdir/dump1.sql", "$tempdir/dump2.sql" ],
235-
'old and new dump match after pg_upgrade');
243+
my $compare_res = compare("$tempdir/dump1.sql", "$tempdir/dump2.sql");
244+
is($compare_res, 0, 'old and new dumps match after pg_upgrade');
245+
246+
# Provide more context if the dumps do not match.
247+
if ($compare_res != 0)
248+
{
249+
my ($stdout, $stderr) =
250+
run_command([ 'diff', "$tempdir/dump1.sql", "$tempdir/dump2.sql" ]);
251+
print "=== diff of $tempdir/dump1.sql and $tempdir/dump2.sql\n";
252+
print "=== stdout ===\n";
253+
print $stdout;
254+
print "=== stderr ===\n";
255+
print $stderr;
256+
print "=== EOF ===\n";
257+
}
236258

237259
done_testing();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy