Re: pg_basebackup test coverage

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_basebackup test coverage
Date: 2020-12-11 08:04:38
Message-ID: X9MoFsnD0j4LwY/y@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 10, 2020 at 10:53:51PM -0800, Noah Misch wrote:
> On Thu, Dec 10, 2020 at 12:32:52PM -0500, Robert Haas wrote:
>> Now, there's nothing to prevent us from running commands like this
>> from the pg_basebackup tests, but it doesn't seem like we could really
>> check anything meaningful. Perhaps we'd notice if the command exited
>> non-zero or didn't produce any output, but it would be nice to verify
>> that the resulting backups are actually correct. The way to do that
>> would seem to be to extract the tar file (and decompress it first, in
>> the -z/-Z case) and then run pg_verifybackup on the result and check
>> that it passes. However, as far as I can tell there's no guarantee
>> that the user has 'tar' or 'gunzip' installed on their system, so I
>> don't see a clean way to do this. A short (but perhaps incomplete)
>> search didn't turn up similar precedents in the existing tests.
>>
>> Any ideas?
>
> I would probe for the commands with "tar -cf- anyfile | tar -xf-" and "echo
> foo | gzip | gunzip". If those fail, skip any test that relies on an
> unavailable command.

Why don't you just use Archive::Tar [1] instead of looking for some system
commands? Combining list_files() with extract(), it is possible to
extract an archive, with or without compression, without hoping for an
equivalent to exist on Windows. That would not be the first time
either that there is a TAP test that skips some tests if a module does
not exist. See for example what psql does with IO::Pty.

[1]: https://metacpan.org/pod/Archive::Tar
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-12-11 08:10:47 Re: Fail Fast In CTAS/CMV If Relation Already Exists To Avoid Unnecessary Rewrite, Planning Costs
Previous Message Kyotaro Horiguchi 2020-12-11 07:50:03 Re: shared-memory based stats collector