|
10 | 10 | use Fcntl qw(:seek);
|
11 | 11 | use PostgreSQL::Test::Cluster;
|
12 | 12 | use PostgreSQL::Test::Utils;
|
13 |
| -use Test::More tests => 110; |
| 13 | +use Test::More tests => 113; |
14 | 14 |
|
15 | 15 | program_help_ok('pg_basebackup');
|
16 | 16 | program_version_ok('pg_basebackup');
|
|
624 | 624 |
|
625 | 625 | $node->safe_psql('postgres', "DROP TABLE corrupt1;");
|
626 | 626 | $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