]> granicus.if.org Git - postgresql/commitdiff
pg_basebackup: Add tests for -X option
authorPeter Eisentraut <peter_e@gmx.net>
Wed, 1 Jul 2015 01:15:29 +0000 (21:15 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 29 Jul 2015 00:31:35 +0000 (20:31 -0400)
Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
src/bin/pg_basebackup/t/010_pg_basebackup.pl
src/test/perl/TestLib.pm

index 4eb4ed102de267d16bdaaddfbe08979d8014a6b2..bf9fdcff6c7d5917e4b734cd26b645c9195000c6 100644 (file)
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 use Cwd;
 use TestLib;
-use Test::More tests => 39;
+use Test::More tests => 44;
 
 program_help_ok('pg_basebackup');
 program_version_ok('pg_basebackup');
@@ -46,6 +46,10 @@ command_ok([ 'pg_basebackup', '-D', "$tempdir/backup" ],
        'pg_basebackup runs');
 ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
 
+is_deeply([sort(slurp_dir("$tempdir/backup/pg_xlog/"))],
+                 [sort qw(. .. archive_status)],
+                 'no WAL files copied');
+
 command_ok(
        [   'pg_basebackup', '-D', "$tempdir/backup2", '--xlogdir',
                "$tempdir/xlog2" ],
@@ -145,3 +149,10 @@ ok(-f "$tempdir/backupR/recovery.conf", 'recovery.conf was created');
 my $recovery_conf = slurp_file "$tempdir/backupR/recovery.conf";
 like($recovery_conf, qr/^standby_mode = 'on'$/m, 'recovery.conf sets standby_mode');
 like($recovery_conf, qr/^primary_conninfo = '.*port=$ENV{PGPORT}.*'$/m, 'recovery.conf sets primary_conninfo');
+
+command_ok([ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ],
+       'pg_basebackup -X fetch runs');
+ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), 'WAL files copied');
+command_ok([ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ],
+       'pg_basebackup -X stream runs');
+ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), 'WAL files copied');
index ca287456b40455d82eb9dd8bc698c1b83a1dea8d..f0379b72256ee3ae36d92566ee2471c09ce63eae 100644 (file)
@@ -11,6 +11,7 @@ our @EXPORT = qw(
   start_test_server
   restart_test_server
   psql
+  slurp_dir
   slurp_file
   system_or_bail
   system_log
@@ -176,6 +177,15 @@ sub psql
        run [ 'psql', '-X', '-q', '-d', $dbname, '-f', '-' ], '<', \$sql or die;
 }
 
+sub slurp_dir
+{
+       my ($dir) = @_;
+       opendir(my $dh, $dir) or die;
+       my @direntries = readdir $dh;
+       closedir $dh;
+       return @direntries;
+}
+
 sub slurp_file
 {
        local $/;