aboutsummaryrefslogtreecommitdiff
path: root/contrib/basebackup_to_shell/t/001_basic.pl
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-01-22 14:47:13 +0900
committerMichael Paquier <michael@paquier.xyz>2025-01-22 14:47:13 +0900
commitce1b0f9da03e1cebc293f60b378079b22bd7cc0f (patch)
tree78c3030de2cc9d201168e8297b5754bf35e37fd2 /contrib/basebackup_to_shell/t/001_basic.pl
parent4a0e7314f11ee03adfe9df945598c068b4179314 (diff)
downloadpostgresql-ce1b0f9da03e1cebc293f60b378079b22bd7cc0f.tar.gz
postgresql-ce1b0f9da03e1cebc293f60b378079b22bd7cc0f.zip
Improve grammar of options for command arrays in TAP tests
This commit rewrites a good chunk of the command arrays in TAP tests with a grammar based on the following rules: - Fat commas are used between option names and their values, making it clear to both humans and perltidy that values and names are bound together. This is particularly useful for the readability of multi-line command arrays, and there are plenty of them in the TAP tests. Most of the test code is updated to use this style. Some commands used parenthesis to show the link, or attached values and options in a single string. These are updated to use fat commas instead. - Option names are switched to use their long names, making them more self-documented. Based on a suggestion by Andrew Dunstan. - Add some trailing commas after the last item in multi-line arrays, which is a common perl style. Not all the places are taken care of, but this covers a very good chunk of them. Author: Dagfinn Ilmari Mannsåker Reviewed-by: Michael Paquier, Peter Smith, Euler Taveira Discussion: https://postgr.es/m/87jzc46d8u.fsf@wibble.ilmari.org
Diffstat (limited to 'contrib/basebackup_to_shell/t/001_basic.pl')
-rw-r--r--contrib/basebackup_to_shell/t/001_basic.pl30
1 files changed, 18 insertions, 12 deletions
diff --git a/contrib/basebackup_to_shell/t/001_basic.pl b/contrib/basebackup_to_shell/t/001_basic.pl
index 5b1c7894c4a..6ffc89433a9 100644
--- a/contrib/basebackup_to_shell/t/001_basic.pl
+++ b/contrib/basebackup_to_shell/t/001_basic.pl
@@ -25,7 +25,7 @@ my $node = PostgreSQL::Test::Cluster->new('primary');
# This is only needed on Windows machines that don't use UNIX sockets.
$node->init(
'allows_streaming' => 1,
- 'auth_extra' => [ '--create-role', 'backupuser' ]);
+ 'auth_extra' => [ '--create-role' => 'backupuser' ]);
$node->append_conf('postgresql.conf',
"shared_preload_libraries = 'basebackup_to_shell'");
@@ -37,15 +37,19 @@ $node->safe_psql('postgres', 'CREATE ROLE trustworthy');
# to keep test times reasonable. Using @pg_basebackup_defs as the first
# element of the array passed to IPC::Run interpolate the array (as it is
# not a reference to an array)...
-my @pg_basebackup_defs = ('pg_basebackup', '--no-sync', '-cfast');
+my @pg_basebackup_defs =
+ ('pg_basebackup', '--no-sync', '--checkpoint' => 'fast');
# This particular test module generally wants to run with -Xfetch, because
# -Xstream is not supported with a backup target, and with -U backupuser.
-my @pg_basebackup_cmd = (@pg_basebackup_defs, '-U', 'backupuser', '-Xfetch');
+my @pg_basebackup_cmd = (
+ @pg_basebackup_defs,
+ '--username' => 'backupuser',
+ '--wal-method' => 'fetch');
# Can't use this module without setting basebackup_to_shell.command.
$node->command_fails_like(
- [ @pg_basebackup_cmd, '--target', 'shell' ],
+ [ @pg_basebackup_cmd, '--target' => 'shell' ],
qr/shell command for backup is not configured/,
'fails if basebackup_to_shell.command is not set');
@@ -64,13 +68,13 @@ $node->reload();
# Should work now.
$node->command_ok(
- [ @pg_basebackup_cmd, '--target', 'shell' ],
+ [ @pg_basebackup_cmd, '--target' => 'shell' ],
'backup with no detail: pg_basebackup');
verify_backup('', $backup_path, "backup with no detail");
# Should fail with a detail.
$node->command_fails_like(
- [ @pg_basebackup_cmd, '--target', 'shell:foo' ],
+ [ @pg_basebackup_cmd, '--target' => 'shell:foo' ],
qr/a target detail is not permitted because the configured command does not include %d/,
'fails if detail provided without %d');
@@ -87,19 +91,19 @@ $node->reload();
# Should fail due to lack of permission.
$node->command_fails_like(
- [ @pg_basebackup_cmd, '--target', 'shell' ],
+ [ @pg_basebackup_cmd, '--target' => 'shell' ],
qr/permission denied to use basebackup_to_shell/,
'fails if required_role not granted');
# Should fail due to lack of a detail.
$node->safe_psql('postgres', 'GRANT trustworthy TO backupuser');
$node->command_fails_like(
- [ @pg_basebackup_cmd, '--target', 'shell' ],
+ [ @pg_basebackup_cmd, '--target' => 'shell' ],
qr/a target detail is required because the configured command includes %d/,
'fails if %d is present and detail not given');
# Should work.
-$node->command_ok([ @pg_basebackup_cmd, '--target', 'shell:bar' ],
+$node->command_ok([ @pg_basebackup_cmd, '--target' => 'shell:bar' ],
'backup with detail: pg_basebackup');
verify_backup('bar.', $backup_path, "backup with detail");
@@ -133,9 +137,11 @@ sub verify_backup
# Verify.
$node->command_ok(
[
- 'pg_verifybackup', '-n',
- '-m', "${backup_dir}/${prefix}backup_manifest",
- '-e', $extract_path
+ 'pg_verifybackup',
+ '--no-parse-wal',
+ '--manifest-path' => "${backup_dir}/${prefix}backup_manifest",
+ '--exit-on-error',
+ $extract_path
],
"$test_name: backup verifies ok");
}