Skip to content

Commit ffb828f

Browse files
committed
PG-1870 Pre-generate pg_tde files for TAP tests
This is currently only added for meson, but could also be added for make. This has to be setup before the actual TAP tests are run as they are run in parallel and as such would all try to setup the template at the same time if we let them use the same folder for it without it being pre-generated. This seems to shorten the test suite run-time by ~25% on my laptop, so it seems worth doing.
1 parent 97972f8 commit ffb828f

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

meson.build

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,6 +3445,48 @@ sys.exit(sp.returncode)
34453445
env: test_env,
34463446
suite: ['setup'])
34473447

3448+
test_tde_template_dir = test_install_destdir / 'pg_tde_template'
3449+
test_env.set('TDE_TEMPLATE_DIR', test_tde_template_dir)
3450+
3451+
test('init_tde_files',
3452+
find_program('sh', required: true, native: true),
3453+
args: [
3454+
'-c', '''
3455+
set -e
3456+
3457+
if [ -z "$TDE_MODE" ]; then
3458+
exit;
3459+
fi
3460+
3461+
set -e
3462+
3463+
PATH="$1":$PATH
3464+
TMP_DATA_DIR=$(mktemp -d)
3465+
3466+
rm -rf "$2"
3467+
mkdir "$2"
3468+
3469+
pg_ctl -D "$TMP_DATA_DIR" init -o '--set shared_preload_libraries=pg_tde'
3470+
3471+
postgres --single -F -j -D "$TMP_DATA_DIR" postgres << SQL
3472+
CREATE EXTENSION pg_tde;
3473+
SELECT pg_tde_add_global_key_provider_file('global_test_provider', '$2/pg_tde_test_keys');
3474+
SELECT pg_tde_create_key_using_global_key_provider('test_default_key', 'global_test_provider');
3475+
SELECT pg_tde_set_default_key_using_global_key_provider('test_default_key', 'global_test_provider');
3476+
SQL
3477+
3478+
cp -RPp "$TMP_DATA_DIR/pg_tde" "$2/pg_tde"
3479+
rm -rf "$TMP_DATA_DIR"
3480+
''',
3481+
'init_tde_files',
3482+
temp_install_bindir,
3483+
test_tde_template_dir
3484+
],
3485+
priority: setup_tests_priority - 2,
3486+
timeout: 300,
3487+
is_parallel: false,
3488+
env: test_env,
3489+
suite: ['setup'])
34483490

34493491

34503492
###############################################################

src/test/perl/PostgreSQL/Test/TdeCluster.pm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,17 @@ sub pg_tde_dir
135135
sub _tde_init_principal_key
136136
{
137137
my ($self) = @_;
138+
my $tde_template_dir;
138139

139-
my $tde_template_dir =
140-
$PostgreSQL::Test::Utils::tmp_check . '/pg_tde_template';
140+
if (defined($ENV{TDE_TEMPLATE_DIR}))
141+
{
142+
$tde_template_dir = $ENV{TDE_TEMPLATE_DIR};
143+
}
144+
else
145+
{
146+
$tde_template_dir =
147+
$PostgreSQL::Test::Utils::tmp_check . '/pg_tde_template';
148+
}
141149

142150
unless (-e $tde_template_dir)
143151
{

0 commit comments

Comments
 (0)