diff options
| author | Michael Paquier | 2025-01-22 05:47:13 +0000 |
|---|---|---|
| committer | Michael Paquier | 2025-01-22 05:47:13 +0000 |
| commit | ce1b0f9da03e1cebc293f60b378079b22bd7cc0f (patch) | |
| tree | 78c3030de2cc9d201168e8297b5754bf35e37fd2 /src/bin/pg_checksums | |
| parent | 4a0e7314f11ee03adfe9df945598c068b4179314 (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/[email protected]
Diffstat (limited to 'src/bin/pg_checksums')
| -rw-r--r-- | src/bin/pg_checksums/t/002_actions.pl | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index f81108e86c4..339c1537a46 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -44,9 +44,10 @@ sub check_relation_corruption # corrupted yet. command_ok( [ - 'pg_checksums', '--check', - '-D', $pgdata, - '--filenode', $relfilenode_corrupted + 'pg_checksums', + '--check', + '--pgdata' => $pgdata, + '--filenode' => $relfilenode_corrupted, ], "succeeds for single relfilenode on tablespace $tablespace with offline cluster" ); @@ -57,9 +58,10 @@ sub check_relation_corruption # Checksum checks on single relfilenode fail $node->command_checks_all( [ - 'pg_checksums', '--check', - '-D', $pgdata, - '--filenode', $relfilenode_corrupted + 'pg_checksums', + '--check', + '--pgdata' => $pgdata, + '--filenode' => $relfilenode_corrupted, ], 1, [qr/Bad checksums:.*1/], @@ -69,7 +71,7 @@ sub check_relation_corruption # Global checksum checks fail as well $node->command_checks_all( - [ 'pg_checksums', '--check', '-D', $pgdata ], + [ 'pg_checksums', '--check', '--pgdata' => $pgdata ], 1, [qr/Bad checksums:.*1/], [qr/checksum verification failed/], @@ -79,7 +81,8 @@ sub check_relation_corruption $node->start; $node->safe_psql('postgres', "DROP TABLE $table;"); $node->stop; - $node->command_ok([ 'pg_checksums', '--check', '-D', $pgdata ], + $node->command_ok( + [ 'pg_checksums', '--check', '--pgdata' => $pgdata ], "succeeds again after table drop on tablespace $tablespace"); $node->start; @@ -122,11 +125,12 @@ append_to_file "$pgdata/global/.DS_Store", "foo" unless ($Config{osname} eq 'darwin'); # Enable checksums. -command_ok([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ], +command_ok([ 'pg_checksums', '--enable', '--no-sync', '--pgdata' => $pgdata ], "checksums successfully enabled in cluster"); # Successive attempt to enable checksums fails. -command_fails([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ], +command_fails( + [ 'pg_checksums', '--enable', '--no-sync', '--pgdata' => $pgdata ], "enabling checksums fails if already enabled"); # Control file should know that checksums are enabled. @@ -137,12 +141,12 @@ command_like( # Disable checksums again. Flush result here as that should be cheap. command_ok( - [ 'pg_checksums', '--disable', '-D', $pgdata ], + [ 'pg_checksums', '--disable', '--pgdata' => $pgdata ], "checksums successfully disabled in cluster"); # Successive attempt to disable checksums fails. command_fails( - [ 'pg_checksums', '--disable', '--no-sync', '-D', $pgdata ], + [ 'pg_checksums', '--disable', '--no-sync', '--pgdata' => $pgdata ], "disabling checksums fails if already disabled"); # Control file should know that checksums are disabled. @@ -152,7 +156,7 @@ command_like( 'checksums disabled in control file'); # Enable checksums again for follow-up tests. -command_ok([ 'pg_checksums', '--enable', '--no-sync', '-D', $pgdata ], +command_ok([ 'pg_checksums', '--enable', '--no-sync', '--pgdata' => $pgdata ], "checksums successfully enabled in cluster"); # Control file should know that checksums are enabled. @@ -162,21 +166,31 @@ command_like( 'checksums enabled in control file'); # Checksums pass on a newly-created cluster -command_ok([ 'pg_checksums', '--check', '-D', $pgdata ], +command_ok([ 'pg_checksums', '--check', '--pgdata' => $pgdata ], "succeeds with offline cluster"); # Checksums are verified if no other arguments are specified command_ok( - [ 'pg_checksums', '-D', $pgdata ], + [ 'pg_checksums', '--pgdata' => $pgdata ], "verifies checksums as default action"); # Specific relation files cannot be requested when action is --disable # or --enable. command_fails( - [ 'pg_checksums', '--disable', '--filenode', '1234', '-D', $pgdata ], + [ + 'pg_checksums', + '--disable', + '--filenode' => '1234', + '--pgdata' => $pgdata + ], "fails when relfilenodes are requested and action is --disable"); command_fails( - [ 'pg_checksums', '--enable', '--filenode', '1234', '-D', $pgdata ], + [ + 'pg_checksums', + '--enable', + '--filenode' => '1234', + '--pgdata' => $pgdata + ], "fails when relfilenodes are requested and action is --enable"); # Test postgres -C for an offline cluster. @@ -187,8 +201,10 @@ command_fails( # account on Windows. command_checks_all( [ - 'pg_ctl', 'start', '-D', $pgdata, '-s', '-o', - '-C data_checksums -c log_min_messages=fatal' + 'pg_ctl', 'start', + '--silent', + '--pgdata' => $pgdata, + '-o' => '-C data_checksums -c log_min_messages=fatal', ], 1, [qr/^on$/], @@ -197,7 +213,7 @@ command_checks_all( # Checks cannot happen with an online cluster $node->start; -command_fails([ 'pg_checksums', '--check', '-D', $pgdata ], +command_fails([ 'pg_checksums', '--check', '--pgdata' => $pgdata ], "fails with online cluster"); # Check corruption of table on default tablespace. @@ -224,7 +240,7 @@ sub fail_corrupt append_to_file $file_name, "foo"; $node->command_checks_all( - [ 'pg_checksums', '--check', '-D', $pgdata ], + [ 'pg_checksums', '--check', '--pgdata' => $pgdata ], 1, [qr/^$/], [qr/could not read block 0 in file.*$file\":/], @@ -242,7 +258,7 @@ $node->stop; # when verifying checksums. mkdir "$tablespace_dir/PG_99_999999991/"; append_to_file "$tablespace_dir/PG_99_999999991/foo", "123"; -command_ok([ 'pg_checksums', '--check', '-D', $pgdata ], +command_ok([ 'pg_checksums', '--check', '--pgdata' => $pgdata ], "succeeds with foreign tablespace"); # Authorized relation files filled with corrupted data cause the |
