diff --git a/src/bin/pg_resetwal/t/001_basic.pl b/src/bin/pg_resetwal/t/001_basic.pl index 1b157cb555..474ece99c7 100644 --- a/src/bin/pg_resetwal/t/001_basic.pl +++ b/src/bin/pg_resetwal/t/001_basic.pl @@ -3,7 +3,7 @@ use warnings; use PostgresNode; use TestLib; -use Test::More tests => 11; +use Test::More tests => 16; program_help_ok('pg_resetwal'); program_version_ok('pg_resetwal'); @@ -15,3 +15,29 @@ $node->init; command_like([ 'pg_resetwal', '-n', $node->data_dir ], qr/checkpoint/, 'pg_resetwal -n produces output'); + +# Reset WAL after segment has been removed +my $pgwal = $node->data_dir . '/pg_wal'; + +unlink("$pgwal/000000010000000000000001") == 1 + or BAIL_OUT("unable to remove 000000010000000000000001"); + +is_deeply( + [sort(slurp_dir($pgwal))], [sort(qw(. .. archive_status))], 'no WAL'); + +$node->command_ok(['pg_resetwal', '-D', $node->data_dir], 'recreate pg_wal'); + +is_deeply( + [sort(slurp_dir($pgwal))], + [sort(qw(. .. archive_status 000000010000000000000002))], + 'WAL recreated'); + +# Reset to specific WAL segment +$node->command_ok( + ['pg_resetwal', '-l', '000000070000000700000007', '-D', $node->data_dir], + 'set to specific WAL'); + +is_deeply( + [sort(slurp_dir($pgwal))], + [sort(qw(. .. archive_status 000000070000000700000007))], + 'WAL recreated');