Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 94e7e77

Browse files
committed
pg_combinebackup: Fix PITR comparison test in 002_compare_backups
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
1 parent f5dec4e commit 94e7e77

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/bin/pg_combinebackup/t/002_compare_backups.pl

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use strict;
44
use warnings FATAL => 'all';
5-
use File::Compare;
5+
use File::Compare qw(compare_text);
66
use PostgreSQL::Test::Cluster;
77
use PostgreSQL::Test::Utils;
88
use Test::More;
@@ -175,17 +175,23 @@
175175
$pitr1->connstr('postgres'),
176176
],
177177
'dump from PITR 1');
178-
$pitr1->command_ok(
178+
$pitr2->command_ok(
179179
[
180180
'pg_dumpall', '-f',
181181
$dump2, '--no-sync',
182182
'--no-unlogged-table-data', '-d',
183-
$pitr1->connstr('postgres'),
183+
$pitr2->connstr('postgres'),
184184
],
185185
'dump from PITR 2');
186186

187-
# Compare the two dumps, there should be no differences.
188-
my $compare_res = compare($dump1, $dump2);
187+
# Compare the two dumps, there should be no differences other than
188+
# the tablespace paths.
189+
my $compare_res = compare_text(
190+
$dump1, $dump2,
191+
sub {
192+
s{create tablespace .* location .*\btspitr\K[12]}{N}i for @_;
193+
return $_[0] ne $_[1];
194+
});
189195
note($dump1);
190196
note($dump2);
191197
is($compare_res, 0, "dumps are identical");

0 commit comments

Comments
 (0)