Skip to content

Commit 50e1441

Browse files
committed
Add TAP tests for pg_basebackup with compression
pg_basebackup is able to use gzip to compress the contents of backups with the tar format, but there were no tests for that. This adds a minimalistic set of tests to check the contents of such base backups, including sanity checks on the contents generated with gzip commands. The tests are skipped if Postgres is compiled --without-zlib, and the checks based on the gzip command are skipped if nothing can be found, following the same model as the existing tests for pg_receivewal. Reviewed-by: Georgios Kokolatos Discussion: https://postgr.es/m/Yb3GEgWwcu4wZDuA@paquier.xyz
1 parent 000f3ad commit 50e1441

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Fcntl qw(:seek);
1111
use PostgreSQL::Test::Cluster;
1212
use PostgreSQL::Test::Utils;
13-
use Test::More tests => 110;
13+
use Test::More tests => 113;
1414

1515
program_help_ok('pg_basebackup');
1616
program_version_ok('pg_basebackup');
@@ -624,3 +624,38 @@
624624

625625
$node->safe_psql('postgres', "DROP TABLE corrupt1;");
626626
$node->safe_psql('postgres', "DROP TABLE corrupt2;");
627+
628+
note "Testing pg_basebackup with compression methods";
629+
630+
# Check ZLIB compression if available.
631+
SKIP:
632+
{
633+
skip "postgres was not built with ZLIB support", 3
634+
if (!check_pg_config("#define HAVE_LIBZ 1"));
635+
636+
$node->command_ok(
637+
[
638+
'pg_basebackup', '-D',
639+
"$tempdir/backup_gzip", '--compress',
640+
'1', '--no-sync',
641+
'--format', 't'
642+
],
643+
'pg_basebackup with --compress');
644+
645+
# Verify that the stored files are generated with their expected
646+
# names.
647+
my @zlib_files = glob "$tempdir/backup_gzip/*.tar.gz";
648+
is(scalar(@zlib_files), 2,
649+
"two files created with gzip (base.tar.gz and pg_wal.tar.gz)");
650+
651+
# Check the integrity of the files generated.
652+
my $gzip = $ENV{GZIP_PROGRAM};
653+
skip "program gzip is not found in your system", 1
654+
if ( !defined $gzip
655+
|| $gzip eq ''
656+
|| system_log($gzip, '--version') != 0);
657+
658+
my $gzip_is_valid = system_log($gzip, '--test', @zlib_files);
659+
is($gzip_is_valid, 0, "gzip verified the integrity of compressed data");
660+
rmtree("$tempdir/backup_gzip");
661+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy