diff --git a/contrib/pg_tde/meson.build b/contrib/pg_tde/meson.build index 3565a73b86d..59bb5a21c70 100644 --- a/contrib/pg_tde/meson.build +++ b/contrib/pg_tde/meson.build @@ -114,6 +114,8 @@ tap_tests = [ 't/011_unlogged_tables.pl', 't/012_replication.pl', 't/013_crash_recovery.pl', + 't/014_pg_waldump_basic.pl', + 't/015_pg_waldump_fullpage.pl', ] tests += { diff --git a/src/bin/pg_waldump/t/003_basic_encrypted.pl b/contrib/pg_tde/t/014_pg_waldump_basic.pl similarity index 83% rename from src/bin/pg_waldump/t/003_basic_encrypted.pl rename to contrib/pg_tde/t/014_pg_waldump_basic.pl index 9f064f0c205..09315cf39d4 100644 --- a/src/bin/pg_waldump/t/003_basic_encrypted.pl +++ b/contrib/pg_tde/t/014_pg_waldump_basic.pl @@ -27,8 +27,12 @@ shared_preload_libraries = 'pg_tde' $node->start; $node->safe_psql('postgres', "CREATE EXTENSION IF NOT EXISTS pg_tde;"); -$node->safe_psql('postgres', "SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');");; -$node->safe_psql('postgres', "SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');"); +$node->safe_psql('postgres', + "SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');" +); +$node->safe_psql('postgres', + "SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');" +); $node->append_conf( 'postgresql.conf', q{ @@ -128,48 +132,74 @@ command_fails_like( [ 'pg_waldump', 'foo', 'bar' ], qr/error: could not locate WAL file "foo"/, 'start file not found'); -command_like([ 'pg_waldump', '-k', $node->data_dir. '/pg_tde', $node->data_dir . '/pg_wal/' . $start_walfile ], - qr/./, 'runs with start segment specified'); +command_like( + [ + 'pg_waldump', '-k', + $node->data_dir . '/pg_tde', + $node->data_dir . '/pg_wal/' . $start_walfile + ], + qr/./, + 'runs with start segment specified'); command_fails_like( - [ 'pg_waldump', '-k', $node->data_dir. '/pg_tde', $node->data_dir . '/pg_wal/' . $start_walfile, 'bar' ], + [ + 'pg_waldump', '-k', + $node->data_dir . '/pg_tde', + $node->data_dir . '/pg_wal/' . $start_walfile, 'bar' + ], qr/error: could not open file "bar"/, 'end file not found'); command_like( [ 'pg_waldump', - '-k', $node->data_dir. '/pg_tde', + '-k', + $node->data_dir . '/pg_tde', $node->data_dir . '/pg_wal/' . $start_walfile, $node->data_dir . '/pg_wal/' . $end_walfile ], qr/./, 'runs with start and end segment specified'); command_fails_like( - [ 'pg_waldump', '-p', $node->data_dir, '-k', $node->data_dir. '/pg_tde' ], + [ + 'pg_waldump', '-p', $node->data_dir, '-k', + $node->data_dir . '/pg_tde' + ], qr/error: no start WAL location given/, 'path option requires start location'); command_like( [ - 'pg_waldump', '-p', $node->data_dir, '--start', - $start_lsn, '--end', $end_lsn, - '-k', $node->data_dir. '/pg_tde' + 'pg_waldump', '-p', + $node->data_dir, '--start', + $start_lsn, '--end', + $end_lsn, '-k', + $node->data_dir . '/pg_tde' ], qr/./, 'runs with path option and start and end locations'); command_fails_like( - [ 'pg_waldump', '-k', $node->data_dir. '/pg_tde', '-p', $node->data_dir, '--start', $start_lsn ], + [ + 'pg_waldump', '-k', + $node->data_dir . '/pg_tde', '-p', + $node->data_dir, '--start', + $start_lsn + ], qr/error: error in WAL record at/, 'falling off the end of the WAL results in an error'); command_like( [ - 'pg_waldump', '--quiet', - '-k', $node->data_dir. '/pg_tde', + 'pg_waldump', '--quiet', '-k', + $node->data_dir . '/pg_tde', $node->data_dir . '/pg_wal/' . $start_walfile ], qr/^$/, 'no output with --quiet option'); command_fails_like( - [ 'pg_waldump', '--quiet', '-k', $node->data_dir. '/pg_tde', '-p', $node->data_dir, '--start', $start_lsn ], + [ + 'pg_waldump', '--quiet', + '-k', $node->data_dir . '/pg_tde', + '-p', $node->data_dir, + '--start', $start_lsn + ], qr/error: error in WAL record at/, 'errors are shown with --quiet'); @@ -187,9 +217,8 @@ command_fails_like( my (@cmd, $stdout, $stderr, $result); @cmd = ( - 'pg_waldump', '-k', $node->data_dir. '/pg_tde', - '--start', $new_start, - $node->data_dir . '/pg_wal/' . $start_walfile); + 'pg_waldump', '-k', $node->data_dir . '/pg_tde', + '--start', $new_start, $node->data_dir . '/pg_wal/' . $start_walfile); $result = IPC::Run::run \@cmd, '>', \$stdout, '2>', \$stderr; ok($result, "runs with start segment and start LSN specified"); like($stderr, qr/first record is after/, 'info message printed'); @@ -206,8 +235,11 @@ sub test_pg_waldump my (@cmd, $stdout, $stderr, $result, @lines); @cmd = ( - 'pg_waldump', '-k', $node->data_dir. '/pg_tde', '-p', $node->data_dir, - '--start', $start_lsn, '--end', $end_lsn); + 'pg_waldump', '-k', + $node->data_dir . '/pg_tde', '-p', + $node->data_dir, '--start', + $start_lsn, '--end', + $end_lsn); push @cmd, @opts; $result = IPC::Run::run \@cmd, '>', \$stdout, '2>', \$stderr; ok($result, "pg_waldump @opts: runs ok"); diff --git a/src/bin/pg_waldump/t/004_save_fullpage_encrypted.pl b/contrib/pg_tde/t/015_pg_waldump_fullpage.pl similarity index 91% rename from src/bin/pg_waldump/t/004_save_fullpage_encrypted.pl rename to contrib/pg_tde/t/015_pg_waldump_fullpage.pl index f737daa4232..877ff2d3459 100644 --- a/src/bin/pg_waldump/t/004_save_fullpage_encrypted.pl +++ b/contrib/pg_tde/t/015_pg_waldump_fullpage.pl @@ -41,8 +41,12 @@ shared_preload_libraries = 'pg_tde' $node->start; $node->safe_psql('postgres', "CREATE EXTENSION IF NOT EXISTS pg_tde;"); -$node->safe_psql('postgres', "SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');");; -$node->safe_psql('postgres', "SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');"); +$node->safe_psql('postgres', + "SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');" +); +$node->safe_psql('postgres', + "SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');" +); $node->append_conf( 'postgresql.conf', q{ @@ -84,7 +88,7 @@ ok(-f $walfile, "Got a WAL file"); $node->command_ok( [ 'pg_waldump', '--quiet', - '-k', $node->data_dir. '/pg_tde', + '-k', $node->data_dir . '/pg_tde', '--save-fullpage', "$tmp_folder/raw", '--relation', $relation, $walfile diff --git a/src/bin/pg_waldump/meson.build b/src/bin/pg_waldump/meson.build index cab9de90846..2d9d67a02ed 100644 --- a/src/bin/pg_waldump/meson.build +++ b/src/bin/pg_waldump/meson.build @@ -42,8 +42,6 @@ tests += { 'tests': [ 't/001_basic.pl', 't/002_save_fullpage.pl', - 't/003_basic_encrypted.pl', - 't/004_save_fullpage_encrypted.pl', ], }, }