Skip to content

Add tests for logical replication, pg_dump/restore, and 2PC under encryption - #1

Merged
jdatcmd merged 1 commit into
mainfrom
tests/replication-dump-2pc
Jul 7, 2026
Merged

Add tests for logical replication, pg_dump/restore, and 2PC under encryption#1
jdatcmd merged 1 commit into
mainfrom
tests/replication-dump-2pc

Conversation

@jdatcmd

@jdatcmd jdatcmd commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fills test-coverage gaps for encrypted-data behavior that the existing suite did not exercise. Each new test verifies both correctness and that data stays encrypted at rest, and all three are perltidy-clean against PostgreSQL's perltidyrc.

Gap analysis

The suite already covered physical/streaming replication (t/replication.pl), pg_rewind, pg_basebackup, crash recovery, WAL archiving, and single-node logical decoding (test_decoding in t/wal_encrypt.pl). It did not cover:

Scenario Before Added
Logical replication (publisher to subscriber) none (only single-node decoding) t/logical_replication.pl
pg_dump / restore round trip of encrypted data none t/pg_dump_restore.pl
Two-phase commit (prepared transactions) none t/prepared_xact.pl

New tests

  • t/logical_replication.pl — two independent clusters, publisher and subscriber, each with its own key. The publisher has WAL encryption on, so logical changes are decoded from encrypted WAL. Verifies initial table sync and incremental insert/update/delete of an encrypted tde_heap table, that the subscriber's copy is itself encrypted, and that replicated rows are ciphertext on disk. A guard asserts WAL encryption is actually enabled. (9 subtests.)

  • t/pg_dump_restore.pl — logical dump/restore round trip. Confirms the dump records the tde_heap access method, the data restores into a database with its own key, the restored table is re-encrypted at rest, and its data is ciphertext on disk. (9 subtests.)

  • t/prepared_xact.pl — two-phase commit on an encrypted table with WAL encryption on. A prepared transaction is left uncommitted, the server is crashed, and after recovery the prepared transaction still exists and COMMIT PREPARED applies the encrypted changes; ROLLBACK PREPARED is also exercised. (8 subtests.)

Testing

All pass on native PostgreSQL 18 (built with the open_pg_tde core patch), alongside the existing t/replication.pl (7 subtests). Each new file is perltidy-clean.

Generated with Claude Code

…ryption

Fill coverage gaps for encrypted-data behavior that the existing suite did not
exercise. Each test verifies both correctness and that data stays encrypted at
rest, and all are perltidy-clean.

- t/logical_replication.pl: two-node publisher/subscriber logical replication
  with WAL encryption on the publisher, so logical changes are decoded from
  encrypted WAL. Checks initial sync and incremental insert/update/delete of an
  encrypted (tde_heap) table, that the subscriber's copy is itself encrypted,
  and that the replicated rows are ciphertext on disk. (The existing
  t/replication.pl covers physical streaming replication.)

- t/pg_dump_restore.pl: logical dump/restore round trip of a database with
  encrypted tables. Confirms the dump records the tde_heap access method, the
  data restores into a database with its own key, and the restored table is
  re-encrypted at rest.

- t/prepared_xact.pl: two-phase commit on an encrypted table, including that a
  prepared transaction survives a crash and replays from encrypted WAL, then
  COMMIT PREPARED and ROLLBACK PREPARED behave correctly.

Register all three in meson.build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jdatcmd
jdatcmd merged commit 518ba30 into main Jul 7, 2026
22 of 35 checks passed
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.

2 participants