diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9120d6a1..43b0ae45 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -60,7 +60,7 @@ jobs: run: src/ci_scripts/build.sh ${{ inputs.build_type }} - name: Add build and install to artifact tar file - run: tar -czf artifacts.tar src postgres pginst + run: tar -czf artifacts.tar src build postgres pginst - name: Upload build artifacts uses: actions/upload-artifact@v7 @@ -113,13 +113,12 @@ jobs: with: name: log-test-${{ inputs.pg_version }}-${{ inputs.os }}-${{ inputs.compiler }}-${{ inputs.build_type }} path: | - src/regress_install - src/regress_install.log - src/regression.diffs - src/regression.out - src/results - src/t/results - src/tmp_check + build/meson-logs/testlog.txt + build/regress_install + build/regress_install.log + build/regression.diffs + build/results + build/testrun retention-days: 3 test-psp-with-tde: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ffb8d45d..0b7f5af9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,7 +47,7 @@ jobs: run: src/ci_scripts/build-and-install-psp.sh coverage - name: Build pg_tde - run: src/ci_scripts/build.sh debug + run: src/ci_scripts/build.sh coverage - name: Setup kmip and vault run: src/ci_scripts/setup-keyring-servers.sh @@ -57,9 +57,9 @@ jobs: - name: Process coverage run: | - geninfo -o coverage.info --no-external --rc lcov_branch_coverage=1 -i . - geninfo -o coverage.info --no-external --rc lcov_branch_coverage=1 . - working-directory: src + geninfo -o coverage.info --rc lcov_branch_coverage=1 -i . + geninfo -o coverage.info --rc lcov_branch_coverage=1 . + working-directory: build - name: Upload coverage data to codecov.io uses: codecov/codecov-action@v5 @@ -68,7 +68,7 @@ jobs: fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} disable_search: true - files: coverage.info + files: ../build/coverage.info working-directory: src - name: Report on test fail @@ -77,11 +77,10 @@ jobs: with: name: coverage-testlog path: | - src/regress_install - src/regress_install.log - src/regression.diffs - src/regression.out - src/results - src/t/results - src/tmp_check + build/meson-logs/testlog.txt + build/regress_install + build/regress_install.log + build/regression.diffs + build/results + build/testrun retention-days: 3 diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml new file mode 100644 index 00000000..d054e9a3 --- /dev/null +++ b/.github/workflows/make.yml @@ -0,0 +1,67 @@ +name: Build and test with make +on: + pull_request: + paths-ignore: + - documentation/** + push: + branches: + - main + paths-ignore: + - documentation/** + +env: + pg_version: 18 + +jobs: + run: + name: Run + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - name: Clone repository + uses: actions/checkout@v5 + with: + path: src + submodules: recursive + + - name: Clone postgres repository + uses: actions/checkout@v5 + with: + path: postgres + repository: percona/postgres.git + ref: PSP_REL_${{ env.pg_version }}_STABLE + + # KMIP server don't support Python 3.12 for now: https://github.com/OpenKMIP/PyKMIP/pull/707 + - name: Downgrade python to 3.11 + uses: actions/setup-python@v6 + with: + python-version: 3.11 + + - name: Install dependencies + run: src/ci_scripts/ubuntu-deps.sh + + - name: Build postgres + run: src/ci_scripts/build-and-install-psp.sh debugoptimized + + - name: Build pg_tde + run: src/ci_scripts/make-build.sh + + - name: Setup kmip and vault + run: src/ci_scripts/setup-keyring-servers.sh + + - name: Run pg_tde tests + run: src/ci_scripts/make-test.sh + + - name: Report on test fail + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: make-testlog + path: | + src/regress_install + src/regress_install.log + src/regression.diffs + src/regression.out + src/results + src/tmp_check + retention-days: 3 diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 5d663543..e8e7c173 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -66,11 +66,10 @@ jobs: name: sanitizers-testlog path: | sanitize.log.* - src/regress_install - src/regress_install.log - src/regression.diffs - src/regression.out - src/results - src/t/results - src/tmp_check + build/meson-logs/testlog.txt + build/regress_install + build/regress_install.log + build/regression.diffs + build/results + build/testrun retention-days: 3 diff --git a/.gitignore b/.gitignore index 120a45e9..f9db711f 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,6 @@ __pycache__ # Generated subdirectories /log/ /results/ -/t/results/ /tmp_check/ /regress_install/ /regress_install.log diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b23656e3..70db3f9a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,39 +68,36 @@ To build `pg_tde` from source code, you require the following: * git * make -* gcc -* pg_config +* gcc or clang +* Percona Server for PostgreSQL 17 or later Refer to the [Building from source code](https://github.com/percona/pg_tde?tab=readme-ov-file#building-from-sources-for-community-postgresql) section for guidelines. ### Run tests -When you work, you should periodically run tests to check that your changes don’t break existing code. - -You can find the tests in the `sql` directory. +You can find the tests in the `sql` and `t` directories. #### Run manually 1. Change the directory to `pg_tde` -**NOTE**: Make sure `postgres` user is the owner of the `pg_tde` directory +2. Build and install `pg_tde` with the following command: -2. Start the tests - 1. If you built PostgreSQL from PGDG, use the following command: + ```sh + make PG_CONFIG=/path/to/postgresql/bin/pg_config install + ``` - ```sh - make installcheck - ``` +3. Start Percona Server for PostgreSQL - 2. If you installed PostgreSQL server from Percona Distribution for PostgreSQL, use the following command: +4. Run the tests using the following command: - ```sh - sudo su postgres bash -c 'make installcheck USE_PGXS=1' - ``` + ```sh + make PG_CONFIG=/path/to/postgresql/bin/pg_config installcheck + ``` #### Run automatically -The tests are run automatically with GitHub actions once you commit and push your changes. Make sure all tests are successfully passed before you proceed. +The tests are run automatically with GitHub actions once you create a pull request. ## Documentation contribution diff --git a/ci_scripts/build-and-install-psp.sh b/ci_scripts/build-and-install-psp.sh index 4883df2e..6043c662 100755 --- a/ci_scripts/build-and-install-psp.sh +++ b/ci_scripts/build-and-install-psp.sh @@ -37,7 +37,7 @@ case "$1" in *) echo "Unknown build type: $1" - echo "Please use one of the following: debug, debugoptimized, sanitize" + echo "Please use one of the following: debug, debugoptimized, coverage, sanitize" exit 1 ;; esac diff --git a/ci_scripts/build.sh b/ci_scripts/build.sh index 433f9e76..836f1154 100755 --- a/ci_scripts/build.sh +++ b/ci_scripts/build.sh @@ -4,31 +4,40 @@ set -e SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" PG_CONFIG="$SCRIPT_DIR/../../pginst/bin/pg_config" -CFLAGS=-Werror - -cd "$SCRIPT_DIR/.." +BUILD_TYPE= +ARGS= case "$1" in debug) echo "Building with debug option" + BUILD_TYPE=$1 ;; debugoptimized) echo "Building with debugoptimized option" - CFLAGS+=" -O2" + BUILD_TYPE=$1 + ;; + + coverage) + echo "Building with coverage option" + BUILD_TYPE=debug + ARGS+=-Db_coverage=true ;; sanitize) echo "Building with sanitize option" - CFLAGS+=" -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-inline-functions" + BUILD_TYPE=debug + ARGS+=" -Dc_args=['-fsanitize=address','-fsanitize=undefined','-fno-omit-frame-pointer','-fno-inline-functions']" + ARGS+=" -Dc_link_args=['-fsanitize=address','-fsanitize=undefined']" ;; *) echo "Unknown build type: $1" - echo "Please use one of the following: debug, debugoptimized, sanitize" + echo "Please use one of the following: debug, debugoptimized, coverage, sanitize" exit 1 ;; esac -export CFLAGS -make PG_CONFIG="$PG_CONFIG" install -j +cd "$SCRIPT_DIR/.." +meson setup --buildtype="$BUILD_TYPE" -Dpg_config="$PG_CONFIG" -Dwerror=true $ARGS ../build +meson install -C ../build diff --git a/ci_scripts/dump-typedefs.sh b/ci_scripts/dump-typedefs.sh index 3a3d0d7f..ea650a0c 100755 --- a/ci_scripts/dump-typedefs.sh +++ b/ci_scripts/dump-typedefs.sh @@ -8,7 +8,7 @@ set -e SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" -cd "$SCRIPT_DIR/.." +cd "$SCRIPT_DIR/../../build" if ! test -f pg_tde.so; then echo "pg_tde.so doesn't exists, run build.sh first in debug mode" @@ -19,4 +19,4 @@ fi ../postgres/src/tools/find_typedef . wget -q -O - "https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_17_STABLE" wget -q -O - "https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_18_STABLE" -) | sort -u > typedefs.list +) | sort -u > ../src/typedefs.list diff --git a/ci_scripts/macos-deps.sh b/ci_scripts/macos-deps.sh index c7510fa7..bed39528 100755 --- a/ci_scripts/macos-deps.sh +++ b/ci_scripts/macos-deps.sh @@ -15,7 +15,8 @@ DEPS=( lz4 openssl zstd - + # Build pg_tde + meson # Run pgperltidy perltidy ) diff --git a/ci_scripts/make-build.sh b/ci_scripts/make-build.sh new file mode 100755 index 00000000..b0fa0f46 --- /dev/null +++ b/ci_scripts/make-build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" +PG_CONFIG="$SCRIPT_DIR/../../pginst/bin/pg_config" + +cd "$SCRIPT_DIR/.." + +export CFLAGS="-Werror -O2" +make PG_CONFIG="$PG_CONFIG" install -j diff --git a/ci_scripts/make-test.sh b/ci_scripts/make-test.sh new file mode 100755 index 00000000..46364460 --- /dev/null +++ b/ci_scripts/make-test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" + +cd "$SCRIPT_DIR/.." + +OPTS='--set shared_preload_libraries=pg_tde' + +../pginst/bin/pg_ctl -D regress_install -l regress_install.log init -o "$OPTS" + +../pginst/bin/pg_ctl -D regress_install -l regress_install.log start + +make PG_CONFIG=../pginst/bin/pg_config installcheck + +../pginst/bin/pg_ctl -D regress_install stop diff --git a/ci_scripts/test.sh b/ci_scripts/test.sh index 0f1dac93..6f01eefc 100755 --- a/ci_scripts/test.sh +++ b/ci_scripts/test.sh @@ -4,7 +4,7 @@ set -e SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" -cd "$SCRIPT_DIR/.." +cd "$SCRIPT_DIR/../../build" OPTS='--set shared_preload_libraries=pg_tde' @@ -16,6 +16,6 @@ fi ../pginst/bin/pg_ctl -D regress_install -l regress_install.log start -make PG_CONFIG=../pginst/bin/pg_config installcheck +meson test --timeout-multiplier=0 --print-errorlogs ../pginst/bin/pg_ctl -D regress_install stop diff --git a/ci_scripts/ubuntu-deps.sh b/ci_scripts/ubuntu-deps.sh index b9b28a8b..421bc81b 100755 --- a/ci_scripts/ubuntu-deps.sh +++ b/ci_scripts/ubuntu-deps.sh @@ -40,6 +40,8 @@ DEPS=( xsltproc zlib1g-dev zstd + # pg_tde dependencies + meson # pg_tde test dependencies lcov perltidy diff --git a/fetools/pg18/pg_basebackup/astreamer_inject.c b/fetools/pg18/pg_basebackup/astreamer_inject.c index 7c1e8604..5c713f31 100644 --- a/fetools/pg18/pg_basebackup/astreamer_inject.c +++ b/fetools/pg18/pg_basebackup/astreamer_inject.c @@ -253,7 +253,7 @@ typedef struct astreamer_pg_tde_injector astreamer base; bool skip_file; bool encryped_wal; -} astreamer_pg_tde_injector; +} astreamer_pg_tde_injector; static void astreamer_pg_tde_injector_content(astreamer *streamer, astreamer_member *member, diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..a35bbd52 --- /dev/null +++ b/meson.build @@ -0,0 +1,377 @@ +project('pg_tde', + ['c'], + version: '2.1.2', + meson_version: '>=0.56', +) + +fs = import('fs') + +pg_config = find_program(get_option('pg_config')) + +bindir = run_command(pg_config, '--bindir', check: true).stdout().strip() +includedir = run_command(pg_config, '--includedir', check: true).stdout().strip() +includedir_server = run_command(pg_config, '--includedir-server', check: true).stdout().strip() +libdir = run_command(pg_config, '--libdir', check: true).stdout().strip() +pkgincludedir = run_command(pg_config, '--pkgincludedir', check: true).stdout().strip() +pkglibdir = run_command(pg_config, '--pkglibdir', check: true).stdout().strip() +sharedir = run_command(pg_config, '--sharedir', check: true).stdout().strip() +version = run_command(pg_config, '--version', check: true).stdout().strip() + +cc = meson.get_compiler('c') + +# To make sure we compile code taken from PostgreSQL the safely we need to use +# the same fucntional flags. +# +# These are copied from common_functional_flags in meson.build in PostgreSQL 18. +add_project_arguments(cc.get_supported_arguments([ + '-fno-strict-aliasing', + '-fwrapv', + '-fexcess-precision=standard', +]), language: ['c']) + +# TODO: Why does it seems like they sometimes are in pkglibdir and other times in libdir? +pgport = cc.find_library('pgport', dirs: [pkglibdir, libdir], static: true) +pgcommon = cc.find_library('pgcommon', dirs: [pkglibdir, libdir], static: true) +pgfeutils = cc.find_library('pgfeutils', dirs: [pkglibdir, libdir], static: true) + +pq = cc.find_library('pq', dirs: [libdir]) +crypto = dependency('libcrypto') +ssl = dependency('libssl') +curl = dependency('libcurl') +lz4 = dependency('liblz4', required: false) +z = dependency('zlib') +zstd = dependency('libzstd', required: false) + +major_version = version.split(' ')[1].split('.')[0].to_int() + +fetools = 'fetools/pg@0@'.format(major_version) + +incdirs = include_directories( + 'src/include', + 'src/libkmip/libkmip/include', + fetools / 'include', + includedir_server, + includedir, + pkgincludedir / 'internal', +) + +backend_link_args = [] + +if host_machine.system() == 'darwin' + backend_link_args += ['-bundle_loader', bindir / 'postgres'] +endif + +install_data( + 'pg_tde.control', + 'pg_tde--1.0.sql', + 'pg_tde--1.0--2.0.sql', + 'pg_tde--2.0--2.1.sql', + install_dir: sharedir / 'extension', +) + +kmip = static_library('kmip', + files( + 'src/libkmip/libkmip/src/kmip.c', + 'src/libkmip/libkmip/src/kmip_bio.c', + 'src/libkmip/libkmip/src/kmip_locate.c', + 'src/libkmip/libkmip/src/kmip_memset.c', + ), + c_args: ['-w'], # This is a 3rd party, disable warnings completely + include_directories: incdirs, +) + +shared_module('pg_tde', + files( + 'src/access/pg_tde_tdemap.c', + 'src/access/pg_tde_xlog.c', + 'src/access/pg_tde_xlog_keys.c', + 'src/access/pg_tde_xlog_smgr.c', + 'src/catalog/tde_keyring.c', + 'src/catalog/tde_keyring_parse_opts.c', + 'src/catalog/tde_principal_key.c', + 'src/common/pg_tde_utils.c', + 'src/encryption/enc_aes.c', + 'src/encryption/enc_tde.c', + 'src/keyring/keyring_api.c', + 'src/keyring/keyring_curl.c', + 'src/keyring/keyring_file.c', + 'src/keyring/keyring_kmip.c', + 'src/keyring/keyring_kmip_impl.c', + 'src/keyring/keyring_vault.c', + 'src/pg_tde.c', + 'src/pg_tde_event_capture.c', + 'src/pg_tde_guc.c', + 'src/smgr/pg_tde_smgr.c', + ), + include_directories: incdirs, + install: true, + install_dir: pkglibdir, + dependencies: [crypto, ssl, curl], + name_prefix: '', + link_with: [kmip], + link_args: backend_link_args, +) + +pg_tde_frontend = static_library('pg_tde_frontend', + files( + 'src/access/pg_tde_tdemap.c', + 'src/access/pg_tde_xlog_keys.c', + 'src/catalog/tde_keyring.c', + 'src/catalog/tde_keyring_parse_opts.c', + 'src/catalog/tde_principal_key.c', + 'src/common/pg_tde_utils.c', + 'src/encryption/enc_aes.c', + 'src/encryption/enc_tde.c', + 'src/keyring/keyring_api.c', + 'src/keyring/keyring_curl.c', + 'src/keyring/keyring_file.c', + 'src/keyring/keyring_kmip.c', + 'src/keyring/keyring_kmip_impl.c', + 'src/keyring/keyring_vault.c', + ), + c_args: ['-DFRONTEND'], + dependencies: [pgfeutils, pgcommon, pgport, curl, crypto, ssl], + include_directories: incdirs, + link_with: [kmip], +) + +pg_tde_frontend_xlog = static_library('pg_tde_frontend_xlog', + files( + 'src/access/pg_tde_xlog_smgr.c', + fetools / 'xlogreader.c', + ), + dependencies: [lz4, zstd], + c_args: ['-DFRONTEND'], + include_directories: incdirs, + link_with: [kmip], +) + +executable('pg_tde_change_key_provider', + files('src/bin/pg_tde_change_key_provider.c'), + include_directories: incdirs, + install: true, + install_dir: bindir, + link_with: [pg_tde_frontend], +) + +executable('pg_tde_archive_decrypt', + files('src/bin/pg_tde_archive_decrypt.c'), + include_directories: incdirs, + install: true, + install_dir: bindir, + link_with: [pg_tde_frontend, pg_tde_frontend_xlog], +) + +executable('pg_tde_restore_encrypt', + files('src/bin/pg_tde_restore_encrypt.c'), + include_directories: incdirs, + install: true, + install_dir: bindir, + link_with: [pg_tde_frontend, pg_tde_frontend_xlog], +) + +executable('pg_tde_upgrade', + files('src/bin/pg_tde_upgrade.c'), + include_directories: incdirs, + install: true, + install_dir: bindir, + dependencies: [pgcommon, pgport], +) + +if major_version == 18 + bb_sources = files( + fetools / 'pg_basebackup/receivelog.c', + fetools / 'pg_basebackup/streamutil.c', + fetools / 'pg_basebackup/walmethods.c', + fetools / 'pg_basebackup/pg_basebackup.c', + fetools / 'pg_basebackup/astreamer_inject.c', + ) +else + bb_sources = files( + fetools / 'pg_basebackup/receivelog.c', + fetools / 'pg_basebackup/streamutil.c', + fetools / 'pg_basebackup/walmethods.c', + fetools / 'pg_basebackup/pg_basebackup.c', + fetools / 'pg_basebackup/bbstreamer_file.c', + fetools / 'pg_basebackup/bbstreamer_gzip.c', + fetools / 'pg_basebackup/bbstreamer_inject.c', + fetools / 'pg_basebackup/bbstreamer_lz4.c', + fetools / 'pg_basebackup/bbstreamer_tar.c', + fetools / 'pg_basebackup/bbstreamer_zstd.c', + ) +endif + +executable('pg_tde_basebackup', + bb_sources, + include_directories: incdirs, + install: true, + install_dir: bindir, + dependencies: [pq, z], + link_with: [pg_tde_frontend, pg_tde_frontend_xlog], +) + +executable('pg_tde_checksums', + files( + fetools / 'pg_checksums/pg_checksums.c', + ), + include_directories: incdirs, + install: true, + install_dir: bindir, + link_with: [pg_tde_frontend], +) + +executable('pg_tde_resetwal', + files( + fetools / 'pg_resetwal/pg_resetwal.c', + ), + include_directories: incdirs, + install: true, + install_dir: bindir, + link_with: [pg_tde_frontend, pg_tde_frontend_xlog], +) + +executable('pg_tde_rewind', + files( + fetools / 'pg_rewind/datapagemap.c', + fetools / 'pg_rewind/file_ops.c', + fetools / 'pg_rewind/filemap.c', + fetools / 'pg_rewind/libpq_source.c', + fetools / 'pg_rewind/local_source.c', + fetools / 'pg_rewind/parsexlog.c', + fetools / 'pg_rewind/pg_rewind.c', + fetools / 'pg_rewind/timeline.c', + ), + include_directories: incdirs, + install: true, + install_dir: bindir, + dependencies: [pq], + link_with: [pg_tde_frontend, pg_tde_frontend_xlog], +) + +executable('pg_tde_waldump', + files( + fetools / 'pg_waldump/compat.c', + fetools / 'pg_waldump/pg_waldump.c', + fetools / 'pg_waldump/rmgrdesc.c', + fetools / 'rmgrdesc/brindesc.c', + fetools / 'rmgrdesc/clogdesc.c', + fetools / 'rmgrdesc/committsdesc.c', + fetools / 'rmgrdesc/dbasedesc.c', + fetools / 'rmgrdesc/genericdesc.c', + fetools / 'rmgrdesc/gindesc.c', + fetools / 'rmgrdesc/gistdesc.c', + fetools / 'rmgrdesc/hashdesc.c', + fetools / 'rmgrdesc/heapdesc.c', + fetools / 'rmgrdesc/logicalmsgdesc.c', + fetools / 'rmgrdesc/mxactdesc.c', + fetools / 'rmgrdesc/nbtdesc.c', + fetools / 'rmgrdesc/relmapdesc.c', + fetools / 'rmgrdesc/replorigindesc.c', + fetools / 'rmgrdesc/rmgrdesc_utils.c', + fetools / 'rmgrdesc/seqdesc.c', + fetools / 'rmgrdesc/smgrdesc.c', + fetools / 'rmgrdesc/spgdesc.c', + fetools / 'rmgrdesc/standbydesc.c', + fetools / 'rmgrdesc/tblspcdesc.c', + fetools / 'rmgrdesc/xactdesc.c', + fetools / 'rmgrdesc/xlogdesc.c', + fetools / 'xlogstats.c', + ), + include_directories: incdirs, + install: true, + install_dir: bindir, + c_args: ['-DFRONTEND'], + link_with: [pg_tde_frontend, pg_tde_frontend_xlog], +) + +regress_tests = [ + 'access_control', + 'alter_index', + 'change_access_method', + 'create_database', + 'default_principal_key', + 'delete_principal_key', + 'insert_update_delete', + 'key_provider', + 'kmip_test', + 'partition_table', + 'pg_tde_is_encrypted', + 'recreate_storage', + 'relocate', + 'tablespace', + 'toast_decrypt', + 'vault_v2_test', + 'version', +] + +tap_tests = [ + 't/2pc_replication.pl', + 't/basic.pl', + 't/change_key_provider.pl', + 't/crash_recovery.pl', + 't/key_rotate_tablespace.pl', + 't/keys_update.pl', + 't/key_validation.pl', + 't/multiple_extensions.pl', + 't/pg_basebackup.pl', + 't/pg_resetwal_basic.pl', + 't/pg_resetwal_corrupted.pl', + 't/pg_rewind_basic.pl', + 't/pg_rewind_databases.pl', + 't/pg_rewind_extrafiles.pl', + 't/pg_rewind_growing_files.pl', + 't/pg_rewind_keep_recycled_wals.pl', + 't/pg_rewind_min_recovery_point.pl', + 't/pg_rewind_options.pl', + 't/pg_rewind_pg_xlog_symlink.pl', + 't/pg_rewind_same_timeline.pl', + 't/pg_tde_change_key_provider.pl', + 't/pg_tde_upgrade.pl', + 't/pg_waldump_basic.pl', + 't/pg_waldump_fullpage.pl', + 't/replication.pl', + 't/reuse_relfilenode_in_cache.pl', + 't/rotate_key.pl', + 't/stream_rep.pl', + 't/tde_heap_aes_256.pl', + 't/tde_heap.pl', + 't/unlogged_tables.pl', + 't/wal_archiving.pl', + 't/wal_encrypt.pl', + 't/wal_key_tli.pl', +] + +pg_regress = find_program('pg_regress', dirs: [pkglibdir / 'pgxs/src/test/regress']) + +test('regress', + pg_regress, + protocol: 'tap', + args: [ + '--bindir', bindir, + '--inputdir', meson.current_source_dir(), + ] + regress_tests, +) + +testwrap = files('testwrap') +perl = find_program('perl') +pg_regress = find_program('pg_regress', dirs: [pkglibdir / 'pgxs/src/test/regress']) + +env = environment() +env.prepend('PATH', bindir) +env.set('PG_REGRESS', pg_regress.full_path()) + +foreach test : tap_tests + test(test, + testwrap, + protocol: 'tap', + env: env, + args: [ + fs.stem(fs.name(test)), + meson.project_source_root(), + perl.full_path(), + '-I', meson.project_source_root() / 't', + '-I', pkglibdir / 'pgxs/src/test/perl', + files(test), + ], + ) +endforeach diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..6987c0bd --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('pg_config', type: 'string', value: 'pg_config', + description: 'Path to pg_config executable') diff --git a/t/pgtde.pm b/t/pgtde.pm index d31713d3..de25fef8 100644 --- a/t/pgtde.pm +++ b/t/pgtde.pm @@ -3,6 +3,7 @@ package PGTDE; use PostgreSQL::Test::Cluster; use PostgreSQL::Test::Utils; +use Cwd qw(abs_path); use File::Basename; use File::Compare; use Test::More; @@ -18,7 +19,12 @@ our $out_filename_with_path; our $debug_out_filename_with_path; my $expected_folder = "t/expected"; -my $results_folder = "t/results"; +my $results_folder; + +INIT +{ + $results_folder = "$PostgreSQL::Test::Utils::tmp_check/results"; +} sub psql { @@ -95,8 +101,9 @@ sub setup_files_dir my ($test_name) = $test_filename =~ /([^.]*)/; - $expected_filename_with_path = "${expected_folder}/${test_name}.out"; - $out_filename_with_path = "${results_folder}/${test_name}.out"; + $expected_filename_with_path = + abs_path("${expected_folder}/${test_name}.out"); + $out_filename_with_path = abs_path("${results_folder}/${test_name}.out"); $debug_out_filename_with_path = "${results_folder}/${test_name}.out.debug"; diff --git a/testwrap b/testwrap new file mode 100755 index 00000000..4bda189b --- /dev/null +++ b/testwrap @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +TEST=$1 +SRCDIR=$2 + +mkdir -p testrun +rm -rf "testrun/$TEST" +mkdir "testrun/$TEST" + +export TESTDATADIR=$(pwd)/testrun/$TEST/data +export TESTLOGDIR=$(pwd)/testrun/$TEST/log + +cd "$SRCDIR" + +shift 2 +exec $@