postgres.git / summary / log / commit / refs

commit    73db8f4d17ed4efb7709f1cafd5b1dd0285b0842
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Fri Apr 01 03:45:40 2022 +0000
First released in: 15.0

    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.


src/bin/pg_upgrade/t/002_pg_upgrade.pl | 40 ++++++++++++++++++++++++++-------- 1 file 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(); [parent: 322becb6085c]