|
37 | 37 | "SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'keyring');"
|
38 | 38 | );
|
39 | 39 |
|
| 40 | +# This is a quite ugly dance to make sure the replica starts the state where |
| 41 | +# WAL encryption is enabled and also generate both some plaintext and some |
| 42 | +# encrypted WAL. |
| 43 | +# |
| 44 | +# We do this by taking the base backup while encryption is enabled. Then we |
| 45 | +# turn it off again to generate some plaintext WAL and turn it back on again |
| 46 | +# then generate some encrypted WAL. |
| 47 | + |
40 | 48 | $primary->append_conf('postgresql.conf', "pg_tde.wal_encrypt = on");
|
41 | 49 |
|
| 50 | +$primary->restart; |
| 51 | + |
42 | 52 | $primary->backup('backup', backup_options => [ '-X', 'none' ]);
|
43 | 53 |
|
| 54 | +$primary->append_conf('postgresql.conf', "pg_tde.wal_encrypt = off"); |
| 55 | + |
| 56 | +$primary->restart; |
| 57 | + |
| 58 | +$primary->append_conf('postgresql.conf', "pg_tde.wal_encrypt = on"); |
| 59 | + |
44 | 60 | $primary->safe_psql('postgres',
|
45 | 61 | "CREATE TABLE t1 AS SELECT 'foobar_plain' AS x");
|
46 | 62 |
|
|
79 | 95 | "restore_command = 'pg_tde_restore_encrypt %f %p \"cp $archive_dir/%%f %%p\"'"
|
80 | 96 | );
|
81 | 97 | $replica->append_conf('postgresql.conf', "recovery_target_action = promote");
|
82 |
| -$replica->set_recovery_mode; |
| 98 | +$replica->set_standby_mode; |
83 | 99 | $replica->start;
|
84 | 100 |
|
85 | 101 | $data_dir = $replica->data_dir;
|
86 | 102 |
|
87 |
| -like( |
| 103 | +unlike( |
88 | 104 | `strings $data_dir/pg_wal/0000000100000000000000??`,
|
89 | 105 | qr/foobar_plain/,
|
90 |
| - 'should find foobar_plain in WAL since we use the same key file'); |
| 106 | + 'should not find foobar_plain in WAL since it is encrypted'); |
91 | 107 | unlike(
|
92 | 108 | `strings $data_dir/pg_wal/0000000100000000000000??`,
|
93 | 109 | qr/foobar_enc/,
|
94 | 110 | 'should not find foobar_enc in WAL since it is encrypted');
|
95 | 111 |
|
| 112 | +$replica->promote; |
| 113 | + |
96 | 114 | my $result = $replica->safe_psql('postgres',
|
97 | 115 | 'SELECT * FROM t1 UNION ALL SELECT * FROM t2');
|
98 | 116 |
|
|
0 commit comments