From 3bb5edf7b903232c7be3d890a284cc9e90d15d59 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Tue, 15 Apr 2025 20:58:50 +0200 Subject: [PATCH] Remove pointless white space and comments from TAP tests It removed readability rather than improved it. --- contrib/pg_tde/t/001_basic.pl | 16 ++------- contrib/pg_tde/t/002_rotate_key.pl | 33 ++++--------------- contrib/pg_tde/t/003_remote_config.pl | 14 ++------ contrib/pg_tde/t/004_file_config.pl | 11 ++----- contrib/pg_tde/t/005_multiple_extensions.pl | 11 +------ contrib/pg_tde/t/006_remote_vault_config.pl | 14 ++------ contrib/pg_tde/t/007_tde_heap.pl | 29 ++-------------- contrib/pg_tde/t/008_key_rotate_tablespace.pl | 15 ++------- contrib/pg_tde/t/009_wal_encrypt.pl | 12 ++----- contrib/pg_tde/t/010_change_key_provider.pl | 17 +--------- contrib/pg_tde/t/011_unlogged_tables.pl | 10 +----- 11 files changed, 25 insertions(+), 157 deletions(-) diff --git a/contrib/pg_tde/t/001_basic.pl b/contrib/pg_tde/t/001_basic.pl index 03a6713ed87..1a44006ed27 100644 --- a/contrib/pg_tde/t/001_basic.pl +++ b/contrib/pg_tde/t/001_basic.pl @@ -7,23 +7,18 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; -# Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION IF NOT EXISTS and change out file permissions my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); @@ -35,11 +30,8 @@ PGTDE::append_to_file($stdout); $rt_value = $node->psql('postgres', 'CREATE TABLE test_enc(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap;', extra_params => ['-a']); ok($rt_value == 3, "Failing query"); - -# Restart the server PGTDE::append_to_file("-- server restart"); $node->stop(); - $rt_value = $node->start(); ok($rt_value == 1, "Restart Server"); @@ -55,7 +47,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -79,18 +70,15 @@ PGTDE::append_to_file($strings); $stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_file($stdout); -# Stop the server + $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/002_rotate_key.pl b/contrib/pg_tde/t/002_rotate_key.pl index 040fa593a13..495e19ae697 100644 --- a/contrib/pg_tde/t/002_rotate_key.pl +++ b/contrib/pg_tde/t/002_rotate_key.pl @@ -7,36 +7,27 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; -# Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION IF NOT EXISTS and change out file permissions my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); - $rt_value = $node->psql('postgres', 'CREATE TABLE test_enc(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap;', extra_params => ['-a']); ok($rt_value == 3, "Failing query"); - -# Restart the server PGTDE::append_to_file("-- server restart"); $node->stop(); - $rt_value = $node->start(); ok($rt_value == 1, "Restart Server"); @@ -64,13 +55,12 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -#rotate key +# Rotate key $stdout = $node->psql('postgres', "SELECT pg_tde_set_key_using_database_key_provider('rotated-key1');", extra_params => ['-a']); PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -83,14 +73,12 @@ PGTDE::append_to_file($stderr); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); - -#Again rotate key +# Again rotate key $stdout = $node->safe_psql('postgres', "SELECT pg_tde_set_key_using_database_key_provider('rotated-key2','file-2');", extra_params => ['-a']); PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -103,13 +91,12 @@ PGTDE::append_to_file($stderr); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -#Again rotate key +# Again rotate key $stdout = $node->safe_psql('postgres', "SELECT pg_tde_set_key_using_global_key_provider('rotated-key', 'file-3', false);", extra_params => ['-a']); PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -125,13 +112,12 @@ PGTDE::append_to_file($stdout); # TODO: add method to query current info # And maybe debug tools to show what's in a file keyring? -#Again rotate key +# Again rotate key $stdout = $node->safe_psql('postgres', "SELECT pg_tde_set_key_using_global_key_provider('rotated-keyX', 'file-2', false);", extra_params => ['-a']); PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -148,7 +134,6 @@ $stdout = $node->safe_psql('postgres', 'ALTER SYSTEM SET pg_tde.inherit_global_p PGTDE::append_to_file($stdout); # Things still work after a restart -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -170,9 +155,6 @@ PGTDE::append_to_file($stdout); PGTDE::append_to_file($stdout); PGTDE::append_to_file($stderr); - -# end - $stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc;', extra_params => ['-a']); PGTDE::append_to_file($stdout); @@ -182,18 +164,15 @@ PGTDE::append_to_file($stdout); $rt_value = $node->stop(); $rt_value = $node->start(); -# DROP EXTENSION ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'DROP EXTENSION pg_tde CASCADE;', extra_params => ['-a']); PGTDE::append_to_file($stdout); PGTDE::append_to_file($stderr); -# Stop the server + $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/003_remote_config.pl b/contrib/pg_tde/t/003_remote_config.pl index 5d3376cfd03..d6007f6428f 100644 --- a/contrib/pg_tde/t/003_remote_config.pl +++ b/contrib/pg_tde/t/003_remote_config.pl @@ -7,10 +7,8 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; @@ -22,7 +20,6 @@ use base qw(HTTP::Server::Simple::CGI); my %dispatch = ( '/hello' => \&resp_hello, - # ... ); sub handle_request { @@ -52,10 +49,9 @@ sub resp_hello { } } + my $pid = MyWebServer->new(8888)->background(); - -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; @@ -80,7 +76,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc2 ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -91,20 +86,17 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc2;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_file($stdout); -# Stop the server + $node->stop(); system("kill $pid"); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/004_file_config.pl b/contrib/pg_tde/t/004_file_config.pl index b90a7e2cbf9..f9e55b2f33d 100644 --- a/contrib/pg_tde/t/004_file_config.pl +++ b/contrib/pg_tde/t/004_file_config.pl @@ -7,14 +7,11 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; @@ -42,7 +39,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc1 ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -53,18 +49,15 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc1;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_file($stdout); -# Stop the server + $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/005_multiple_extensions.pl b/contrib/pg_tde/t/005_multiple_extensions.pl index 8db86a24248..d9d970b57d0 100644 --- a/contrib/pg_tde/t/005_multiple_extensions.pl +++ b/contrib/pg_tde/t/005_multiple_extensions.pl @@ -7,7 +7,6 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); my $PG_VERSION_STRING = `pg_config --version`; @@ -17,7 +16,6 @@ if (index(lc($PG_VERSION_STRING), lc("Percona Distribution")) == -1) plan skip_all => "pg_tde test case only for PPG server package install with extensions."; } -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; @@ -32,7 +30,6 @@ open my $conf2, '>>', "/tmp/datafile-location"; print $conf2 "/tmp/keyring_data_file\n"; close $conf2; -# Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); @@ -94,7 +91,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc1 ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -131,24 +127,19 @@ ok($cmdret == 0, "Run pgbench"); ok($cmdret == 0, "SELECT XXX FROM pg_stat_monitor"); PGTDE::append_to_debug_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_stat_monitor;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_debug_file($stdout); -# Stop the server $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/006_remote_vault_config.pl b/contrib/pg_tde/t/006_remote_vault_config.pl index de2f23dd395..38a7cfccac2 100644 --- a/contrib/pg_tde/t/006_remote_vault_config.pl +++ b/contrib/pg_tde/t/006_remote_vault_config.pl @@ -8,10 +8,8 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; @@ -24,7 +22,6 @@ use base qw(HTTP::Server::Simple::CGI); my %dispatch = ( '/token' => \&resp_token, '/url' => \&resp_url, - # ... ); sub handle_request { @@ -60,10 +57,9 @@ sub resp_url { } } + my $pid = MyWebServer->new(8889)->background(); - -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; @@ -88,7 +84,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc2 ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -99,20 +94,17 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc2;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_file($stdout); -# Stop the server + $node->stop(); system("kill -9 $pid"); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/007_tde_heap.pl b/contrib/pg_tde/t/007_tde_heap.pl index e63b1264312..fb574d34566 100644 --- a/contrib/pg_tde/t/007_tde_heap.pl +++ b/contrib/pg_tde/t/007_tde_heap.pl @@ -7,7 +7,6 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); my $PG_VERSION_STRING = `pg_config --version`; @@ -17,44 +16,33 @@ if (index(lc($PG_VERSION_STRING), lc("Percona Server")) == -1) plan skip_all => "pg_tde test case only for Percona Server for PostgreSQL"; } -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; -# Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION IF NOT EXISTS and change out file permissions my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); - $rt_value = $node->psql('postgres', 'CREATE TABLE test_enc(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING tde_heap;', extra_params => ['-a']); ok($rt_value == 3, "Failing query"); - -# Restart the server PGTDE::append_to_file("-- server restart"); $node->stop(); - $rt_value = $node->start(); ok($rt_value == 1, "Restart Server"); $rt_value = $node->psql('postgres', "SELECT pg_tde_add_database_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');", extra_params => ['-a']); $rt_value = $node->psql('postgres', "SELECT pg_tde_set_key_using_database_key_provider('test-db-key','file-vault');", extra_params => ['-a']); - - ######################### test_enc1 (simple create table w tde_heap) - $stdout = $node->safe_psql('postgres', 'CREATE TABLE test_enc1(id SERIAL,k VARCHAR(32),PRIMARY KEY (id)) USING tde_heap;', extra_params => ['-a']); PGTDE::append_to_file($stdout); @@ -100,7 +88,6 @@ $stdout = $node->safe_psql('postgres', 'SET default_table_access_method = "tde_h $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc4 ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); - ######################### test_enc5 (create tde_heap + truncate) $stdout = $node->safe_psql('postgres', 'CREATE TABLE test_enc5(id SERIAL,k VARCHAR(32),PRIMARY KEY (id)) USING tde_heap;', extra_params => ['-a']); @@ -121,7 +108,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc5 ORDER BY id ASC;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -167,9 +153,6 @@ $strings = 'CONTAINS FOO (should be empty): '; $strings .= `strings $tablefile2 | grep foo`; PGTDE::append_to_file($strings); - - - # Verify that we can't see the data in the file my $tablefile3 = $node->safe_psql('postgres', 'SHOW data_directory;'); $tablefile3 .= '/'; @@ -183,9 +166,6 @@ $strings = 'CONTAINS FOO (should be empty): '; $strings .= `strings $tablefile3 | grep foo`; PGTDE::append_to_file($strings); - - - # Verify that we can't see the data in the file my $tablefile4 = $node->safe_psql('postgres', 'SHOW data_directory;'); $tablefile4 .= '/'; @@ -199,8 +179,6 @@ $strings = 'CONTAINS FOO (should be empty): '; $strings .= `strings $tablefile4 | grep foo`; PGTDE::append_to_file($strings); - - $stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc1;', extra_params => ['-a']); PGTDE::append_to_file($stdout); @@ -216,18 +194,15 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc5;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_file($stdout); -# Stop the server + $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/008_key_rotate_tablespace.pl b/contrib/pg_tde/t/008_key_rotate_tablespace.pl index 9113fae4462..7e563b31def 100644 --- a/contrib/pg_tde/t/008_key_rotate_tablespace.pl +++ b/contrib/pg_tde/t/008_key_rotate_tablespace.pl @@ -7,21 +7,17 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); my ($cmdret, $stdout); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; -# Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); @@ -54,23 +50,18 @@ SELECT * FROM country_table; }, extra_params => ['-a']); PGTDE::append_to_file($stdout); - $cmdret = $node->psql('tbc', "SELECT pg_tde_set_key_using_database_key_provider('new-k', 'file-vault');", extra_params => ['-a']); ok($cmdret == 0, "ROTATE KEY"); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $node->stop(); - $rt_value = $node->start(); ok($rt_value == 1, "Restart Server"); $stdout = $node->safe_psql('tbc', 'SELECT * FROM country_table;', extra_params => ['-a']); PGTDE::append_to_file($stdout); - -# DROP EXTENSION $stdout = $node->safe_psql('tbc', 'DROP EXTENSION pg_tde CASCADE;', extra_params => ['-a']); ok($cmdret == 0, "DROP PGTDE EXTENSION"); PGTDE::append_to_file($stdout); @@ -81,14 +72,12 @@ DROP TABLESPACE test_tblspace; }, extra_params => ['-a']); ok($cmdret == 0, "DROP DATABSE"); PGTDE::append_to_file($stdout); -# Stop the server + $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/009_wal_encrypt.pl b/contrib/pg_tde/t/009_wal_encrypt.pl index db6d5f4f0a9..39b9fa4d069 100644 --- a/contrib/pg_tde/t/009_wal_encrypt.pl +++ b/contrib/pg_tde/t/009_wal_encrypt.pl @@ -7,14 +7,11 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; print $conf "wal_level = 'logical'\n"; @@ -37,7 +34,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'ALTER SYSTEM SET pg_tde.wal_encrypt = on;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server, it should work with encryption now PGTDE::append_to_file("-- server restart with wal encryption"); $node->stop(); $rt_value = $node->start(); @@ -72,7 +68,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'ALTER SYSTEM SET pg_tde.wal_encrypt = on;', extra_params => ['-a']); PGTDE::append_to_file($stdout); - PGTDE::append_to_file("-- server restart with wal encryption"); $node->stop(); $rt_value = $node->start(); @@ -101,17 +96,14 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', "SELECT pg_drop_replication_slot('tde_slot');", extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION $stdout = $node->safe_psql('postgres', 'DROP EXTENSION pg_tde;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Stop the server + $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare,0,"Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/010_change_key_provider.pl b/contrib/pg_tde/t/010_change_key_provider.pl index 96977877194..0bbd3d1c119 100644 --- a/contrib/pg_tde/t/010_change_key_provider.pl +++ b/contrib/pg_tde/t/010_change_key_provider.pl @@ -8,14 +8,11 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; @@ -25,11 +22,9 @@ unlink('/tmp/change_key_provider_2.per'); unlink('/tmp/change_key_provider_3.per'); unlink('/tmp/change_key_provider_4.per'); -# Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); -# CREATE EXTENSION IF NOT EXISTS and change out file permissions my ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); @@ -68,7 +63,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -95,7 +89,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -114,7 +107,6 @@ PGTDE::append_to_file($stderr); PGTDE::append_to_file("-- mv /tmp/change_key_provider_2.per /tmp/change_key_provider_3.per"); move('/tmp/change_key_provider_2.per', '/tmp/change_key_provider_3.per'); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -127,12 +119,10 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION (undef, $stdout, $stderr) = $node->psql('postgres', 'DROP EXTENSION pg_tde CASCADE;', extra_params => ['-a']); PGTDE::append_to_file($stdout); PGTDE::append_to_file($stderr); -# CREATE EXTENSION ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'CREATE EXTENSION IF NOT EXISTS pg_tde;', extra_params => ['-a']); ok($cmdret == 0, "CREATE PGTDE EXTENSION"); PGTDE::append_to_file($stdout); @@ -158,7 +148,6 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', "SELECT pg_tde_change_database_key_provider_file('file-vault', '/tmp/change_key_provider_3.per');", extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Restart the server PGTDE::append_to_file("-- server restart"); $rt_value = $node->stop(); $rt_value = $node->start(); @@ -188,19 +177,15 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id;', extra_params => ['-a']); PGTDE::append_to_file($stdout); -# DROP EXTENSION (undef, $stdout, $stderr) = $node->psql('postgres', 'DROP EXTENSION pg_tde CASCADE;', extra_params => ['-a']); PGTDE::append_to_file($stdout); PGTDE::append_to_file($stderr); -# Stop the server $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare, 0, "Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing(); diff --git a/contrib/pg_tde/t/011_unlogged_tables.pl b/contrib/pg_tde/t/011_unlogged_tables.pl index 8c744290421..5c81b922334 100644 --- a/contrib/pg_tde/t/011_unlogged_tables.pl +++ b/contrib/pg_tde/t/011_unlogged_tables.pl @@ -7,19 +7,15 @@ use Test::More; use lib 't'; use pgtde; -# Get file name and CREATE out file name and dirs WHERE requried PGTDE::setup_files_dir(basename($0)); -# CREATE new PostgreSQL node and do initdb my $node = PGTDE->pgtde_init_pg(); my $pgdata = $node->data_dir; -# UPDATE postgresql.conf to include/load pg_tde library open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "shared_preload_libraries = 'pg_tde'\n"; close $conf; -# Start server my $rt_value = $node->start; ok($rt_value == 1, "Start Server"); @@ -43,7 +39,6 @@ PGTDE::append_to_file($stdout); PGTDE::append_to_file("-- kill -9"); $node->kill9(); -# Start server PGTDE::append_to_file("-- server start"); $rt_value = $node->start; ok($rt_value == 1, "Start Server"); @@ -54,14 +49,11 @@ PGTDE::append_to_file($stdout); $stdout = $node->safe_psql('postgres', "INSERT INTO t SELECT generate_series(1, 4);", extra_params => ['-a']); PGTDE::append_to_file($stdout); -# Stop the server $node->stop(); -# compare the expected and out file +# Compare the expected and out file my $compare = PGTDE->compare_results(); -# Test/check if expected and result/out file match. If Yes, test passes. is($compare, 0, "Compare Files: $PGTDE::expected_filename_with_path and $PGTDE::out_filename_with_path files."); -# Done testing for this testcase file. done_testing();