aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-04-01 12:45:40 +0900
committerMichael Paquier <michael@paquier.xyz>2022-04-01 12:45:40 +0900
commit73db8f4d17ed4efb7709f1cafd5b1dd0285b0842 (patch)
tree25f5a72d2ef5a8128ff0abce4209fce973eb634a /src
parent322becb6085cb92d3708635eea61b45776bf27b6 (diff)
downloadpostgresql-73db8f4d17ed4efb7709f1cafd5b1dd0285b0842.tar.gz
postgresql-73db8f4d17ed4efb7709f1cafd5b1dd0285b0842.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_upgrade/t/002_pg_upgrade.pl40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index 36b560bd0cf..05bf161843e 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -4,6 +4,7 @@ use warnings;
use Cwd qw(abs_path getcwd);
use File::Basename qw(dirname);
+use File::Compare;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
@@ -111,8 +112,18 @@ else
$inputdir
];
- $oldnode->command_ok(@regress_command,
- 'regression test run on old instance');
+ my $rc = run_log(@regress_command);
+ 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";
+ }
+ }
}
# Before dumping, get rid of objects not existing or not supported in later
@@ -214,11 +225,9 @@ if (-d $log_path)
{
foreach my $log (glob("$log_path/*"))
{
- note "###########################";
- note "Contents of log file $log";
- note "###########################";
- my $log_contents = slurp_file($log);
- print "$log_contents\n";
+ note "=== contents of $log ===\n";
+ print slurp_file($log);
+ print "=== EOF ===\n";
}
}
@@ -231,7 +240,20 @@ $newnode->run_log(
]);
# Compare the two dumps, there should be no differences.
-command_ok([ 'diff', '-q', "$tempdir/dump1.sql", "$tempdir/dump2.sql" ],
- 'old and new dump match after pg_upgrade');
+my $compare_res = compare("$tempdir/dump1.sql", "$tempdir/dump2.sql");
+is($compare_res, 0, 'old and new dumps match after pg_upgrade');
+
+# Provide more context if the dumps do not match.
+if ($compare_res != 0)
+{
+ my ($stdout, $stderr) =
+ run_command([ 'diff', "$tempdir/dump1.sql", "$tempdir/dump2.sql" ]);
+ print "=== diff of $tempdir/dump1.sql and $tempdir/dump2.sql\n";
+ print "=== stdout ===\n";
+ print $stdout;
+ print "=== stderr ===\n";
+ print $stderr;
+ print "=== EOF ===\n";
+}
done_testing();