From ffb828f413792671399eb7a0a83a9ef5a29e5694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85strand?= Date: Thu, 28 Aug 2025 16:42:55 +0200 Subject: [PATCH] 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. --- meson.build | 42 +++++++++++++++++++++ src/test/perl/PostgreSQL/Test/TdeCluster.pm | 12 +++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index c0542006604..4ff5644c699 100644 --- a/meson.build +++ b/meson.build @@ -3445,6 +3445,48 @@ sys.exit(sp.returncode) env: test_env, suite: ['setup']) +test_tde_template_dir = test_install_destdir / 'pg_tde_template' +test_env.set('TDE_TEMPLATE_DIR', test_tde_template_dir) + +test('init_tde_files', + find_program('sh', required: true, native: true), + args: [ + '-c', ''' +set -e + +if [ -z "$TDE_MODE" ]; then + exit; +fi + +set -e + +PATH="$1":$PATH +TMP_DATA_DIR=$(mktemp -d) + +rm -rf "$2" +mkdir "$2" + +pg_ctl -D "$TMP_DATA_DIR" init -o '--set shared_preload_libraries=pg_tde' + +postgres --single -F -j -D "$TMP_DATA_DIR" postgres << SQL + CREATE EXTENSION pg_tde; + SELECT pg_tde_add_global_key_provider_file('global_test_provider', '$2/pg_tde_test_keys'); + SELECT pg_tde_create_key_using_global_key_provider('test_default_key', 'global_test_provider'); + SELECT pg_tde_set_default_key_using_global_key_provider('test_default_key', 'global_test_provider'); +SQL + +cp -RPp "$TMP_DATA_DIR/pg_tde" "$2/pg_tde" +rm -rf "$TMP_DATA_DIR" +''', + 'init_tde_files', + temp_install_bindir, + test_tde_template_dir + ], + priority: setup_tests_priority - 2, + timeout: 300, + is_parallel: false, + env: test_env, + suite: ['setup']) ############################################################### diff --git a/src/test/perl/PostgreSQL/Test/TdeCluster.pm b/src/test/perl/PostgreSQL/Test/TdeCluster.pm index b943bdac08b..a7a0dd40188 100644 --- a/src/test/perl/PostgreSQL/Test/TdeCluster.pm +++ b/src/test/perl/PostgreSQL/Test/TdeCluster.pm @@ -135,9 +135,17 @@ sub pg_tde_dir sub _tde_init_principal_key { my ($self) = @_; + my $tde_template_dir; - my $tde_template_dir = - $PostgreSQL::Test::Utils::tmp_check . '/pg_tde_template'; + if (defined($ENV{TDE_TEMPLATE_DIR})) + { + $tde_template_dir = $ENV{TDE_TEMPLATE_DIR}; + } + else + { + $tde_template_dir = + $PostgreSQL::Test::Utils::tmp_check . '/pg_tde_template'; + } unless (-e $tde_template_dir) {