From 94e7e77a95ba501955788e1e124b577a665cd85d Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Tue, 17 Dec 2024 09:24:18 +0900 Subject: [PATCH] pg_combinebackup: Fix PITR comparison test in 002_compare_backups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test was creating both the dumps to compare from the same database on the same node, so it would never detect any mismatches when comparing the logical dumps of the two servers. Fixing this issue has revealed that there is a difference in the dumps: the tablespaces paths are different. This commit uses compare_text() with a custom comparison function to erase the difference (slightly tweaked to be able to work with WIN32 and non-WIN32 paths). This way, the non-relevant parts of the tablespace path are ignored from the check with the basic structure of the query string still compared. Author: Dagfinn Ilmari Mannsåker Discussion: https://postgr.es/m/87h67653ns.fsf@wibble.ilmari.org Backpatch-through: 17 --- .../pg_combinebackup/t/002_compare_backups.pl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_combinebackup/t/002_compare_backups.pl b/src/bin/pg_combinebackup/t/002_compare_backups.pl index 63a0255de15..cfdd25471cb 100644 --- a/src/bin/pg_combinebackup/t/002_compare_backups.pl +++ b/src/bin/pg_combinebackup/t/002_compare_backups.pl @@ -2,7 +2,7 @@ use strict; use warnings FATAL => 'all'; -use File::Compare; +use File::Compare qw(compare_text); use PostgreSQL::Test::Cluster; use PostgreSQL::Test::Utils; use Test::More; @@ -175,17 +175,23 @@ $pitr1->command_ok( $pitr1->connstr('postgres'), ], 'dump from PITR 1'); -$pitr1->command_ok( +$pitr2->command_ok( [ 'pg_dumpall', '-f', $dump2, '--no-sync', '--no-unlogged-table-data', '-d', - $pitr1->connstr('postgres'), + $pitr2->connstr('postgres'), ], 'dump from PITR 2'); -# Compare the two dumps, there should be no differences. -my $compare_res = compare($dump1, $dump2); +# Compare the two dumps, there should be no differences other than +# the tablespace paths. +my $compare_res = compare_text( + $dump1, $dump2, + sub { + s{create tablespace .* location .*\btspitr\K[12]}{N}i for @_; + return $_[0] ne $_[1]; + }); note($dump1); note($dump2); is($compare_res, 0, "dumps are identical");