On Sat, Dec 03, 2022 at 11:45:30AM +0900, Michael Paquier wrote: > While this is correct in checking that the contents are compressed > under --with-zlib, this also removes the coverage where we make sure > that this command is able to complete under --without-zlib without > compressing any of the table data files. Hence my point from > upthread: this test had better not use compile_option, but change > glob_pattern depending on if the build uses zlib or not.
In short, I mean something like the attached. I have named the flag content_patterns, and switched it to an array so as we can check that toc.dat is always uncompression and that the other data files are always uncompressed. > In order to check this behavior with defaults_custom_format, perhaps > we could just remove the -Z6 from it or add an extra command for its > default behavior? This is slightly more complicated as there is just one file generated for the compression and non-compression cases, so I have let that as it is now. -- Michael
From 5c583358caed5598fec9abea6750ff7fbd98d269 Mon Sep 17 00:00:00 2001 From: Michael Paquier <mich...@paquier.xyz> Date: Mon, 5 Dec 2022 16:04:57 +0900 Subject: [PATCH v15] Provide coverage for pg_dump default compression for dir format The restore program will succeed regardless of whether the dumped output was compressed or not. This commit implements a portable way to check the contents of the directory via perl's build in filename expansion. --- src/bin/pg_dump/t/002_pg_dump.pl | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 709db0986d..9796d2667f 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -36,6 +36,9 @@ my $tempdir = PostgreSQL::Test::Utils::tempdir; # to test pg_restore's ability to parse manually compressed files # that otherwise pg_dump does not compress on its own (e.g. *.toc). # +# content_patterns is an optional array consisting of strings compilable +# with glob() to check the files generated after a dump. +# # restore_cmd is the pg_restore command to run, if any. Note # that this should generally be used when the pg_dump goes to # a non-text file and that the restore can then be used to @@ -46,6 +49,10 @@ my $tempdir = PostgreSQL::Test::Utils::tempdir; # database and then pg_dump *that* database (or something along # those lines) to validate that part of the process. +my $supports_icu = ($ENV{with_icu} eq 'yes'); +my $supports_lz4 = check_pg_config("#define USE_LZ4 1"); +my $supports_gzip = check_pg_config("#define HAVE_LIBZ 1"); + my %pgdump_runs = ( binary_upgrade => { dump_cmd => [ @@ -213,6 +220,9 @@ my %pgdump_runs = ( }, # Do not use --no-sync to give test coverage for data sync. + # By default, the directory format compresses its contents + # when the code is compiled with gzip support, and lets things + # uncompressed when not compiled with it. defaults_dir_format => { test_key => 'defaults', dump_cmd => [ @@ -224,6 +234,11 @@ my %pgdump_runs = ( "--file=$tempdir/defaults_dir_format.sql", "$tempdir/defaults_dir_format", ], + content_patterns => ["$tempdir/defaults_dir_format/toc.dat", + $supports_gzip ? + "$tempdir/defaults_dir_format/*.dat.gz" : + "$tempdir/defaults_dir_format/*.dat", + ], }, # Do not use --no-sync to give test coverage for data sync. @@ -3920,10 +3935,6 @@ if ($collation_check_stderr !~ /ERROR: /) $collation_support = 1; } -my $supports_icu = ($ENV{with_icu} eq 'yes'); -my $supports_lz4 = check_pg_config("#define USE_LZ4 1"); -my $supports_gzip = check_pg_config("#define HAVE_LIBZ 1"); - # ICU doesn't work with some encodings my $encoding = $node->safe_psql('postgres', 'show server_encoding'); $supports_icu = 0 if $encoding eq 'SQL_ASCII'; @@ -4153,6 +4164,16 @@ foreach my $run (sort keys %pgdump_runs) command_ok(\@full_compress_cmd, "$run: compression commands"); } + if ($pgdump_runs{$run}->{content_patterns}) + { + my $content_patterns = $pgdump_runs{$run}->{content_patterns}; + foreach my $content_pattern (@{$content_patterns}) + { + my @glob_output = glob($content_pattern); + is(scalar(@glob_output) > 0, 1, "$run: content check for $content_pattern"); + } + } + if ($pgdump_runs{$run}->{restore_cmd}) { $node->command_ok(\@{ $pgdump_runs{$run}->{restore_cmd} }, -- 2.38.1
signature.asc
Description: PGP signature