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');
'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" ],
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');
start_test_server
restart_test_server
psql
+ slurp_dir
slurp_file
system_or_bail
system_log
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 $/;