From 04c57939eaf5013f40966f05920438506bce1d07 Mon Sep 17 00:00:00 2001 From: shihao zhong Date: Sun, 4 Oct 2026 23:38:16 -0400 Subject: [PATCH v3 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 Discussion: https://postgr.es/m/CAGRkXqTEM51AHwzvs6QVVrJJDXVD9g5QwrfMYp3-BkM9Ph-G8A@mail.gmail.com --- 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)