Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50e1441

Browse files
committed
Add TAP tests for pg_basebackup with compression
pg_basebackup is able to use gzip to compress the contents of backupswith the tar format, but there were no tests for that. This adds aminimalistic 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 thechecks 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 KokolatosDiscussion:https://postgr.es/m/Yb3GEgWwcu4wZDuA@paquier.xyz
1 parent000f3ad commit50e1441

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 Fcntlqw(:seek);
1111
use PostgreSQL::Test::Cluster;
1212
use PostgreSQL::Test::Utils;
13-
use Test::Moretests=>110;
13+
use Test::Moretests=>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+
||$gzipeq''
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)

[8]ページ先頭

©2009-2025 Movatter.jp