Skip to content

Commit 90102bb

Browse files
committed
pg_basebackup: Add tests for -X option
Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent 36dc30a commit 90102bb

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/bin/pg_basebackup/t/010_pg_basebackup.pl

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use warnings;
33
use Cwd;
44
use TestLib;
5-
use Test::More tests => 39;
5+
use Test::More tests => 44;
66

77
program_help_ok('pg_basebackup');
88
program_version_ok('pg_basebackup');
@@ -46,6 +46,10 @@
4646
'pg_basebackup runs');
4747
ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
4848

49+
is_deeply([sort(slurp_dir("$tempdir/backup/pg_xlog/"))],
50+
[sort qw(. .. archive_status)],
51+
'no WAL files copied');
52+
4953
command_ok(
5054
[ 'pg_basebackup', '-D', "$tempdir/backup2", '--xlogdir',
5155
"$tempdir/xlog2" ],
@@ -145,3 +149,10 @@
145149
my $recovery_conf = slurp_file "$tempdir/backupR/recovery.conf";
146150
like($recovery_conf, qr/^standby_mode = 'on'$/m, 'recovery.conf sets standby_mode');
147151
like($recovery_conf, qr/^primary_conninfo = '.*port=$ENV{PGPORT}.*'$/m, 'recovery.conf sets primary_conninfo');
152+
153+
command_ok([ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ],
154+
'pg_basebackup -X fetch runs');
155+
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), 'WAL files copied');
156+
command_ok([ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ],
157+
'pg_basebackup -X stream runs');
158+
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")), 'WAL files copied');

src/test/perl/TestLib.pm

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ our @EXPORT = qw(
1111
start_test_server
1212
restart_test_server
1313
psql
14+
slurp_dir
1415
slurp_file
1516
system_or_bail
1617
system_log
@@ -176,6 +177,15 @@ sub psql
176177
run [ 'psql', '-X', '-q', '-d', $dbname, '-f', '-' ], '<', \$sql or die;
177178
}
178179

180+
sub slurp_dir
181+
{
182+
my ($dir) = @_;
183+
opendir(my $dh, $dir) or die;
184+
my @direntries = readdir $dh;
185+
closedir $dh;
186+
return @direntries;
187+
}
188+
179189
sub slurp_file
180190
{
181191
local $/;

0 commit comments

Comments
 (0)