Skip to content

Conversation

AndersAstrand
Copy link
Collaborator

@AndersAstrand AndersAstrand commented Aug 14, 2025

This enables wal encryption and table encryption by default when running postgres TAP suite with TDE_MODE=1.

A few tests had to be skipped for various reasons, and some of these should most likely be looked into as they might be actual bugs or test setup issues we can fix.

Use TDE_MODE=1 to enable pg_tde with both wal and relation encryption. Use TDE_MODE_WAL=0 to disable wal encryption and TDE_MODE_SMGR=0 to disable relation encryption.

For example to run the postgres suite with WAL encryption turned on, but not SMGR:
TDE_MODE=1 TDE_MODE_SMGR=0 meson test --no-suite pg_tde

There is also TDE_MODE_NOSKIP=1 which will force all tests to run. This is useful when investigating the test failures that made it necessary to skip some tests.

Copy link
Collaborator

@jeltz jeltz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, especially with Zsolt's proposed changes if they can be implemented reaosnably which generates the files and copies them.

@AndersAstrand AndersAstrand force-pushed the tde/run-postgres-tap-tests-with-wal-encryption branch from 3aac647 to 0e93481 Compare August 15, 2025 09:44
@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.22%. Comparing base (415cb8d) to head (8d7f347).

❌ Your project status has failed because the head coverage (82.22%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@                Coverage Diff                 @@
##           TDE_REL_17_STABLE     #535   +/-   ##
==================================================
  Coverage              82.22%   82.22%           
==================================================
  Files                     25       25           
  Lines                   3246     3246           
  Branches                 512      512           
==================================================
  Hits                    2669     2669           
  Misses                   465      465           
  Partials                 112      112           
Components Coverage Δ
access 84.70% <ø> (ø)
catalog 87.65% <ø> (ø)
common 77.77% <ø> (ø)
encryption 72.97% <ø> (ø)
keyring 73.21% <ø> (ø)
src 94.18% <ø> (ø)
smgr 96.53% <ø> (ø)
transam ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AndersAstrand AndersAstrand force-pushed the tde/run-postgres-tap-tests-with-wal-encryption branch 11 times, most recently from 615c60f to 4ccb15e Compare August 20, 2025 08:26
@dutow dutow force-pushed the TDE_REL_17_STABLE branch from b3b7e89 to 415cb8d Compare August 20, 2025 08:59
@AndersAstrand AndersAstrand force-pushed the tde/run-postgres-tap-tests-with-wal-encryption branch from 4ccb15e to cdd6aa1 Compare August 25, 2025 11:02
@AndersAstrand AndersAstrand marked this pull request as ready for review August 25, 2025 11:06
@AndersAstrand AndersAstrand changed the title Run postgresql TAP suite with WAL encryption enabled PG-1870 Run postgresql TAP suite with WAL encryption enabled Aug 25, 2025
@AndersAstrand AndersAstrand changed the base branch from TDE_REL_17_STABLE to release-17.5.3 August 25, 2025 11:11
@AndersAstrand AndersAstrand force-pushed the tde/run-postgres-tap-tests-with-wal-encryption branch from cdd6aa1 to 3647e68 Compare August 25, 2025 13:34
@AndersAstrand AndersAstrand changed the title PG-1870 Run postgresql TAP suite with WAL encryption enabled PG-1870 Run postgresql TAP suite with pg_tde enabled Aug 25, 2025
@AndersAstrand AndersAstrand force-pushed the tde/run-postgres-tap-tests-with-wal-encryption branch from 3647e68 to 512a3a1 Compare August 25, 2025 14:55
@AndersAstrand AndersAstrand changed the base branch from release-17.5.3 to TDE_REL_17_STABLE August 26, 2025 09:40
@AndersAstrand AndersAstrand force-pushed the tde/run-postgres-tap-tests-with-wal-encryption branch from 512a3a1 to 82e6728 Compare August 26, 2025 09:41
Copy link
Collaborator

@jeltz jeltz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes! Nice also to see some use of single user mode.

my ($self) = @_;

my $tde_template_dir = $ENV{TDE_TEMPLATE_DIR}
if defined($ENV{TDE_TEMPLATE_DIR});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we have not implemented it for make? Just lack of time? The reason should either be in the commit message or a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just didn't care enough about make to do it. Which is probably not a great reason. I am honestly on the fence if we should do it for meson either. Might not be worth the extra complexity.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say I care either way but it should be explained in the commit message.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you emasured the speedup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a hard time doing any type of even preliminary performance testing on my laptop right now because the stupid s1-agent eats so much CPU and it's quite random.

if ($ENV{TDE_MODE_WAL} and not $ENV{TDE_MODE_NOSKIP})
{
plan skip_all =>
"pg_tde_restore_encrypt gets a WAL segment of invalid size";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that is not the issue. The issue is that we use pg_tde_restore_encrypt to restore but a normal copy to archive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the message

This makes sure pg_tde is loaded and keys are setup when running
postgresql TAP suite. No TDE features are enabled at this point.

When running with meson the setup is sped up by creating a template for
the key files before the first test is run.

In make this setup will currently be done once per test file instead of
once for the whole suite.
This enables WAL encryption by default when the TAP tests are run with
TDE_MODE=1. Use TDE_MODE_WAL=0 to disable wal encryption while still
having pg_tde enabled.
This enables table encryption by default in TAP tests when TDE_MODE=1.
Use TDE_MODE_SMGR=0 to turn off table encryption when running with
pg_tde loaded.

The setup for running regress with tde turned on has been slightly
modified to match what is done for TAP tests to let tests that run the
regress suite under TAP work.
@AndersAstrand AndersAstrand force-pushed the tde/run-postgres-tap-tests-with-wal-encryption branch from 82e6728 to 8d7f347 Compare August 27, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants