summaryrefslogtreecommitdiff
path: root/src/bin/pg_resetwal/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 /src/bin/pg_resetwal/t/001_basic.pl
parent4a0e7314f11ee03adfe9df945598c068b4179314 (diff)
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 'src/bin/pg_resetwal/t/001_basic.pl')
-rw-r--r--src/bin/pg_resetwal/t/001_basic.pl81
1 files changed, 42 insertions, 39 deletions
diff --git a/src/bin/pg_resetwal/t/001_basic.pl b/src/bin/pg_resetwal/t/001_basic.pl
index d0bd1f7ace8..323cd483cf3 100644
--- a/src/bin/pg_resetwal/t/001_basic.pl
+++ b/src/bin/pg_resetwal/t/001_basic.pl
@@ -30,7 +30,8 @@ SKIP:
'check PGDATA permissions');
}
-command_ok([ 'pg_resetwal', '-D', $node->data_dir ], 'pg_resetwal runs');
+command_ok([ 'pg_resetwal', '--pgdata' => $node->data_dir ],
+ 'pg_resetwal runs');
$node->start;
is($node->safe_psql("postgres", "SELECT 1;"),
1, 'server running and working after reset');
@@ -46,7 +47,7 @@ command_fails_like(
qr/database server was not shut down cleanly/,
'does not run after immediate shutdown');
command_ok(
- [ 'pg_resetwal', '-f', $node->data_dir ],
+ [ 'pg_resetwal', '--force', $node->data_dir ],
'runs after immediate shutdown with force');
$node->start;
is($node->safe_psql("postgres", "SELECT 1;"),
@@ -80,111 +81,111 @@ command_fails_like(
# error cases
# -c
command_fails_like(
- [ 'pg_resetwal', '-c', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-c' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -c/,
'fails with incorrect -c option');
command_fails_like(
- [ 'pg_resetwal', '-c', '10,bar', $node->data_dir ],
+ [ 'pg_resetwal', '-c' => '10,bar', $node->data_dir ],
qr/error: invalid argument for option -c/,
'fails with incorrect -c option part 2');
command_fails_like(
- [ 'pg_resetwal', '-c', '1,10', $node->data_dir ],
+ [ 'pg_resetwal', '-c' => '1,10', $node->data_dir ],
qr/greater than/,
- 'fails with -c value 1 part 1');
+ 'fails with -c ids value 1 part 1');
command_fails_like(
- [ 'pg_resetwal', '-c', '10,1', $node->data_dir ],
+ [ 'pg_resetwal', '-c' => '10,1', $node->data_dir ],
qr/greater than/,
'fails with -c value 1 part 2');
# -e
command_fails_like(
- [ 'pg_resetwal', '-e', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-e' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -e/,
'fails with incorrect -e option');
command_fails_like(
- [ 'pg_resetwal', '-e', '-1', $node->data_dir ],
+ [ 'pg_resetwal', '-e' => '-1', $node->data_dir ],
qr/must not be -1/,
'fails with -e value -1');
# -l
command_fails_like(
- [ 'pg_resetwal', '-l', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-l' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -l/,
'fails with incorrect -l option');
# -m
command_fails_like(
- [ 'pg_resetwal', '-m', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-m' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -m/,
'fails with incorrect -m option');
command_fails_like(
- [ 'pg_resetwal', '-m', '10,bar', $node->data_dir ],
+ [ 'pg_resetwal', '-m' => '10,bar', $node->data_dir ],
qr/error: invalid argument for option -m/,
'fails with incorrect -m option part 2');
command_fails_like(
- [ 'pg_resetwal', '-m', '0,10', $node->data_dir ],
+ [ 'pg_resetwal', '-m' => '0,10', $node->data_dir ],
qr/must not be 0/,
'fails with -m value 0 part 1');
command_fails_like(
- [ 'pg_resetwal', '-m', '10,0', $node->data_dir ],
+ [ 'pg_resetwal', '-m' => '10,0', $node->data_dir ],
qr/must not be 0/,
'fails with -m value 0 part 2');
# -o
command_fails_like(
- [ 'pg_resetwal', '-o', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-o' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -o/,
'fails with incorrect -o option');
command_fails_like(
- [ 'pg_resetwal', '-o', '0', $node->data_dir ],
+ [ 'pg_resetwal', '-o' => '0', $node->data_dir ],
qr/must not be 0/,
'fails with -o value 0');
# -O
command_fails_like(
- [ 'pg_resetwal', '-O', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-O' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -O/,
'fails with incorrect -O option');
command_fails_like(
- [ 'pg_resetwal', '-O', '-1', $node->data_dir ],
+ [ 'pg_resetwal', '-O' => '-1', $node->data_dir ],
qr/must not be -1/,
'fails with -O value -1');
# --wal-segsize
command_fails_like(
- [ 'pg_resetwal', '--wal-segsize', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '--wal-segsize' => 'foo', $node->data_dir ],
qr/error: invalid value/,
'fails with incorrect --wal-segsize option');
command_fails_like(
- [ 'pg_resetwal', '--wal-segsize', '13', $node->data_dir ],
+ [ 'pg_resetwal', '--wal-segsize' => '13', $node->data_dir ],
qr/must be a power/,
'fails with invalid --wal-segsize value');
# -u
command_fails_like(
- [ 'pg_resetwal', '-u', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-u' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -u/,
'fails with incorrect -u option');
command_fails_like(
- [ 'pg_resetwal', '-u', '1', $node->data_dir ],
+ [ 'pg_resetwal', '-u' => '1', $node->data_dir ],
qr/must be greater than/,
'fails with -u value too small');
# -x
command_fails_like(
- [ 'pg_resetwal', '-x', 'foo', $node->data_dir ],
+ [ 'pg_resetwal', '-x' => 'foo', $node->data_dir ],
qr/error: invalid argument for option -x/,
'fails with incorrect -x option');
command_fails_like(
- [ 'pg_resetwal', '-x', '1', $node->data_dir ],
+ [ 'pg_resetwal', '-x' => '1', $node->data_dir ],
qr/must be greater than/,
'fails with -x value too small');
# run with control override options
-my $out = (run_command([ 'pg_resetwal', '-n', $node->data_dir ]))[0];
+my $out = (run_command([ 'pg_resetwal', '--dry-run', $node->data_dir ]))[0];
$out =~ /^Database block size: *(\d+)$/m or die;
my $blcksz = $1;
-my @cmd = ('pg_resetwal', '-D', $node->data_dir);
+my @cmd = ('pg_resetwal', '--pgdata' => $node->data_dir);
# some not-so-critical hardcoded values
-push @cmd, '-e', 1;
-push @cmd, '-l', '00000001000000320000004B';
-push @cmd, '-o', 100_000;
-push @cmd, '--wal-segsize', 1;
+push @cmd, '--epoch' => 1;
+push @cmd, '--next-wal-file' => '00000001000000320000004B';
+push @cmd, '--next-oid' => 100_000;
+push @cmd, '--wal-segsize' => 1;
# these use the guidance from the documentation
@@ -202,31 +203,33 @@ my (@files, $mult);
# XXX: Should there be a multiplier, similar to the other options?
# -c argument is "old,new"
push @cmd,
- '-c',
+ '--commit-timestamp-ids' =>
sprintf("%d,%d", hex($files[0]) == 0 ? 3 : hex($files[0]), hex($files[-1]));
@files = get_slru_files('pg_multixact/offsets');
$mult = 32 * $blcksz / 4;
-# -m argument is "new,old"
-push @cmd, '-m',
- sprintf("%d,%d",
+# --multixact-ids argument is "new,old"
+push @cmd,
+ '--multixact-ids' => sprintf("%d,%d",
(hex($files[-1]) + 1) * $mult,
hex($files[0]) == 0 ? 1 : hex($files[0] * $mult));
@files = get_slru_files('pg_multixact/members');
$mult = 32 * int($blcksz / 20) * 4;
-push @cmd, '-O', (hex($files[-1]) + 1) * $mult;
+push @cmd, '--multixact-offset' => (hex($files[-1]) + 1) * $mult;
@files = get_slru_files('pg_xact');
$mult = 32 * $blcksz * 4;
push @cmd,
- '-u', (hex($files[0]) == 0 ? 3 : hex($files[0]) * $mult),
- '-x', ((hex($files[-1]) + 1) * $mult);
+ '--oldest-transaction-id' =>
+ (hex($files[0]) == 0 ? 3 : hex($files[0]) * $mult),
+ '--next-transaction-id' => ((hex($files[-1]) + 1) * $mult);
-command_ok([ @cmd, '-n' ], 'runs with control override options, dry run');
+command_ok([ @cmd, '--dry-run' ],
+ 'runs with control override options, dry run');
command_ok(\@cmd, 'runs with control override options');
command_like(
- [ 'pg_resetwal', '-n', $node->data_dir ],
+ [ 'pg_resetwal', '--dry-run', $node->data_dir ],
qr/^Latest checkpoint's NextOID: *100000$/m,
'spot check that control changes were applied');