From 54d885fbfd1a6cd2ecd68505c921fd18a895d296 Mon Sep 17 00:00:00 2001 From: Shihao Date: Mon, 28 Sep 2026 00:06:56 -0700 Subject: [PATCH v1 2/2] Test pg_resetwal backup_label check Check that pg_resetwal fails with backup_label present, with and without --force and --dry-run, and runs again once it is removed. Discussion: https://postgr.es/m/556bef11-938d-45ca-94b3-7143a3cb532d@pgbackrest.org --- src/bin/pg_resetwal/t/001_basic.pl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/bin/pg_resetwal/t/001_basic.pl b/src/bin/pg_resetwal/t/001_basic.pl index f54e9bb4223..e59355fb396 100644 --- a/src/bin/pg_resetwal/t/001_basic.pl +++ b/src/bin/pg_resetwal/t/001_basic.pl @@ -55,6 +55,29 @@ is($node->safe_psql("postgres", "SELECT 1;"), $node->stop; +# A backup_label file blocks pg_resetwal, even with --force or --dry-run. +my $backup_label = $node->data_dir . '/backup_label'; +append_to_file($backup_label, "START WAL LOCATION: 0/2000028\n"); +command_fails_like( + [ 'pg_resetwal', $node->data_dir ], + qr/backup label file "backup_label" exists/, + 'fails with backup_label'); +command_fails_like( + [ 'pg_resetwal', '--force', $node->data_dir ], + qr/backup label file "backup_label" exists/, + 'fails with backup_label even with force'); +command_fails_like( + [ 'pg_resetwal', '--dry-run', $node->data_dir ], + qr/backup label file "backup_label" exists/, + 'fails with backup_label even with dry-run'); +unlink($backup_label) or die "could not remove $backup_label: $!"; +command_ok([ 'pg_resetwal', $node->data_dir ], + 'runs after removing backup_label'); +$node->start; +is($node->safe_psql("postgres", "SELECT 1;"), + 1, 'server running and working after removing backup_label'); +$node->stop; + # check various command-line handling # Note: This test intends to check that a nonexistent data directory -- 2.37.1 (Apple Git-137.1)