pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: pgsql-hackers@lists.postgresql.org
Subject: pg_combinebackup PITR comparison test fix
Date: Sat, 14 Dec 2024 21:57:11 +0000
Message-ID: <87h67653ns.fsf@wibble.ilmari.org> (raw)

Hi hackers,

While I was going through the TAP tests to fix the formatting of command
argument lists to be less confusing, I noticed that pg_combinebackup's
002_compare_backups.pl test accidentally ran pg_dumpall twice against
the same database, thus rendering the tests useless.

Fixing that revealed that there is a difference in the dumps: the
tablespaces have different paths.  pg_dumpall doesn't have an option to
map tablespace paths, so instead I used File::Compare::compare_text()
with a custom comparison function to erase the difference.

- ilmari

Attachments:

0001-Fix-pg_combinebackup-PITR-comparison-test.patch (text/x-diff, 1.9K) download From d8f186e79fceb881a225c7b612e074d8956da1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org> Date: Sat, 14 Dec 2024 21:08:16 +0000 Subject: [PATCH] Fix pg_combinebackup PITR comparison test The test was creating both the dumps to compare from the same DB, so would never detect any mismatches. Fixing that revealed that there is a difference in the dumps: the tablespaces have different paths. pg_dumpall doesn't have an option to map tablespace paths, so use compare_text() with a custom comparison function to erase the difference. --- .../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..6bf48971734 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->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 '.*/tspitr\K[12]}{N}i for @_; + return $_[0] ne $_[1]; + }); note($dump1); note($dump2); is($compare_res, 0, "dumps are identical"); -- 2.39.5

view thread (6+ messages)  latest in thread

Message-ID: <87h67653ns.fsf@wibble.ilmari.org>
Permalink:  ../87h67653ns.fsf@wibble.ilmari.org/
Also on:    postgresql.org/message-id/87h67653ns.fsf@wibble.ilmari.org

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: ilmari@ilmari.org
  Subject: Re: pg_combinebackup PITR comparison test fix
  In-Reply-To: <87h67653ns.fsf@wibble.ilmari.org>
  References: <87h67653ns.fsf@wibble.ilmari.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox