Skip to content

Commit 2c7a809

Browse files
committed
Add WAL encryption to TDE pg_rewind tests
Now the TDE version of pg_rewind tests runs with the WAL encryption ON
1 parent 0c3afd7 commit 2c7a809

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

contrib/pg_tde/t/RewindTest.pm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use warnings FATAL => 'all';
3636

3737
use Carp;
3838
use Exporter 'import';
39+
use File::Basename;
3940
use File::Copy;
4041
use File::Path qw(rmtree);
4142
use IPC::Run qw(run);
@@ -113,6 +114,13 @@ sub setup_cluster
113114
my $extra_name = shift; # Used to differentiate clusters
114115
my $extra = shift; # Extra params for initdb
115116

117+
my ($test_name) = basename($0) =~ /([^.]*)/;
118+
my ($test_mode) = $extra_name //= 'default';
119+
my $tde_keyring_file =
120+
"/tmp/pg_tde_rewind_test_${test_name}_${test_mode}.per";
121+
122+
unlink($tde_keyring_file);
123+
116124
# Initialize primary, data checksums are mandatory
117125
$node_primary =
118126
PostgreSQL::Test::Cluster->new(
@@ -132,7 +140,31 @@ sub setup_cluster
132140
'postgresql.conf', qq(
133141
wal_keep_size = 320MB
134142
allow_in_place_tablespaces = on
143+
144+
shared_preload_libraries = 'pg_tde'
135145
));
146+
147+
$node_primary->start;
148+
149+
$node_primary->safe_psql('postgres',
150+
"CREATE EXTENSION IF NOT EXISTS pg_tde;");
151+
$node_primary->safe_psql('postgres',
152+
"SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','${tde_keyring_file}');"
153+
);
154+
$node_primary->safe_psql('postgres',
155+
"SELECT pg_tde_create_key_using_global_key_provider('global-db-principal-key', 'file-keyring-wal');"
156+
);
157+
$node_primary->safe_psql('postgres',
158+
"SELECT pg_tde_set_server_key_using_global_key_provider('global-db-principal-key', 'file-keyring-wal');"
159+
);
160+
161+
$node_primary->append_conf(
162+
'postgresql.conf', q{
163+
pg_tde.wal_encrypt = on
164+
});
165+
166+
$node_primary->stop;
167+
136168
return;
137169
}
138170

0 commit comments

Comments
 (0)