|
20 | 20 | # test_key indicates that a given run should simply use the same
|
21 | 21 | # set of like/unlike tests as another run, and which run that is.
|
22 | 22 | #
|
| 23 | +# compile_option indicates if the commands run depend on a compilation |
| 24 | +# option, if any. This can be used to control if tests should be |
| 25 | +# skipped when a build dependency is not satisfied. |
| 26 | +# |
23 | 27 | # dump_cmd is the pg_dump command to run, which is an array of
|
24 | 28 | # the full command and arguments to run. Note that this is run
|
25 | 29 | # using $node->command_ok(), so the port does not need to be
|
26 | 30 | # specified and is pulled from $PGPORT, which is set by the
|
27 | 31 | # PostgreSQL::Test::Cluster system.
|
28 | 32 | #
|
| 33 | +# compress_cmd is the utility command for (de)compression, if any. |
| 34 | +# Note that this should generally be used on pg_dump's output |
| 35 | +# either to generate a text file to run the through the tests, or |
| 36 | +# to test pg_restore's ability to parse manually compressed files |
| 37 | +# that otherwise pg_dump does not compress on its own (e.g. *.toc). |
| 38 | +# |
29 | 39 | # restore_cmd is the pg_restore command to run, if any. Note
|
30 | 40 | # that this should generally be used when the pg_dump goes to
|
31 | 41 | # a non-text file and that the restore can then be used to
|
|
54 | 64 | "$tempdir/binary_upgrade.dump",
|
55 | 65 | ],
|
56 | 66 | },
|
| 67 | + |
| 68 | +# Do not use --no-sync to give test coverage for data sync. |
| 69 | +compression_gzip_custom=> { |
| 70 | +test_key=>'compression', |
| 71 | +compile_option=>'gzip', |
| 72 | +dump_cmd=> [ |
| 73 | +'pg_dump','--format=custom', |
| 74 | +'--compress=1',"--file=$tempdir/compression_gzip_custom.dump", |
| 75 | +'postgres', |
| 76 | +], |
| 77 | +restore_cmd=> [ |
| 78 | +'pg_restore', |
| 79 | +"--file=$tempdir/compression_gzip_custom.sql", |
| 80 | +"$tempdir/compression_gzip_custom.dump", |
| 81 | +], |
| 82 | +}, |
| 83 | + |
| 84 | +# Do not use --no-sync to give test coverage for data sync. |
| 85 | +compression_gzip_dir=> { |
| 86 | +test_key=>'compression', |
| 87 | +compile_option=>'gzip', |
| 88 | +dump_cmd=> [ |
| 89 | +'pg_dump','--jobs=2', |
| 90 | +'--format=directory','--compress=1', |
| 91 | +"--file=$tempdir/compression_gzip_dir",'postgres', |
| 92 | +], |
| 93 | +# Give coverage for manually compressed blob.toc files during |
| 94 | +# restore. |
| 95 | +compress_cmd=> { |
| 96 | +program=>$ENV{'GZIP_PROGRAM'}, |
| 97 | +args=> ['-f',"$tempdir/compression_gzip_dir/blobs.toc", ], |
| 98 | +}, |
| 99 | +restore_cmd=> [ |
| 100 | +'pg_restore','--jobs=2', |
| 101 | +"--file=$tempdir/compression_gzip_dir.sql", |
| 102 | +"$tempdir/compression_gzip_dir", |
| 103 | +], |
| 104 | +}, |
| 105 | + |
| 106 | +compression_gzip_plain=> { |
| 107 | +test_key=>'compression', |
| 108 | +compile_option=>'gzip', |
| 109 | +dump_cmd=> [ |
| 110 | +'pg_dump','--format=plain','-Z1', |
| 111 | +"--file=$tempdir/compression_gzip_plain.sql.gz",'postgres', |
| 112 | +], |
| 113 | +# Decompress the generated file to run through the tests. |
| 114 | +compress_cmd=> { |
| 115 | +program=>$ENV{'GZIP_PROGRAM'}, |
| 116 | +args=> ['-d',"$tempdir/compression_gzip_plain.sql.gz", ], |
| 117 | +}, |
| 118 | +}, |
57 | 119 | clean=> {
|
58 | 120 | dump_cmd=> [
|
59 | 121 | 'pg_dump',
|
|
424 | 486 | binary_upgrade=> 1,
|
425 | 487 | clean=> 1,
|
426 | 488 | clean_if_exists=> 1,
|
| 489 | +compression=> 1, |
427 | 490 | createdb=> 1,
|
428 | 491 | defaults=> 1,
|
429 | 492 | exclude_dump_test_schema=> 1,
|
|
3098 | 3161 | binary_upgrade => 1,
|
3099 | 3162 | clean => 1,
|
3100 | 3163 | clean_if_exists => 1,
|
| 3164 | +compression => 1, |
3101 | 3165 | createdb => 1,
|
3102 | 3166 | defaults => 1,
|
3103 | 3167 | exclude_test_table => 1,
|
|
3171 | 3235 | binary_upgrade => 1,
|
3172 | 3236 | clean => 1,
|
3173 | 3237 | clean_if_exists => 1,
|
| 3238 | +compression => 1, |
3174 | 3239 | createdb => 1,
|
3175 | 3240 | defaults => 1,
|
3176 | 3241 | exclude_dump_test_schema => 1,
|
|
3833 | 3898 | $collation_support = 1;
|
3834 | 3899 | }
|
3835 | 3900 |
|
3836 |
| -# Determine whether build supports LZ4. |
3837 |
| -my$supports_lz4 = check_pg_config("#define USE_LZ4 1"); |
| 3901 | +# Determine whether build supports LZ4 and gzip. |
| 3902 | +my$supports_lz4 = check_pg_config("#define USE_LZ4 1"); |
| 3903 | +my$supports_gzip = check_pg_config("#define HAVE_LIBZ 1"); |
3838 | 3904 |
|
3839 | 3905 | # Create additional databases for mutations of schema public
|
3840 | 3906 | $node->psql('postgres', 'create database regress_pg_dump_test;');
|
|
3947 | 4013 | my$test_key =$run;
|
3948 | 4014 | my$run_db = 'postgres';
|
3949 | 4015 |
|
| 4016 | +# Skip command-level tests for gzip if there is no support for it. |
| 4017 | +if ( defined($pgdump_runs{$run}->{compile_option}) |
| 4018 | +&&$pgdump_runs{$run}->{compile_option} eq 'gzip' |
| 4019 | +&& !$supports_gzip) |
| 4020 | +{ |
| 4021 | +note "$run: skipped due to no gzip support"; |
| 4022 | +next; |
| 4023 | +} |
| 4024 | +
|
3950 | 4025 | $node->command_ok(\@{$pgdump_runs{$run}->{dump_cmd} },
|
3951 | 4026 | "$run: pg_dump runs");
|
3952 | 4027 |
|
| 4028 | +if ($pgdump_runs{$run}->{compress_cmd}) |
| 4029 | +{ |
| 4030 | +my ($compress_cmd) =$pgdump_runs{$run}->{compress_cmd}; |
| 4031 | +my$compress_program =$compress_cmd->{program}; |
| 4032 | +
|
| 4033 | +# Skip the rest of the test if the compression program is |
| 4034 | +# not defined. |
| 4035 | +next if (!defined($compress_program) ||$compress_program eq ''); |
| 4036 | +
|
| 4037 | +my@full_compress_cmd = |
| 4038 | + ($compress_cmd->{program}, @{$compress_cmd->{args} }); |
| 4039 | +command_ok(\@full_compress_cmd, "$run: compression commands"); |
| 4040 | +} |
| 4041 | +
|
3953 | 4042 | if ($pgdump_runs{$run}->{restore_cmd})
|
3954 | 4043 | {
|
3955 | 4044 | $node->command_ok(\@{$pgdump_runs{$run}->{restore_cmd} },
|
|