Skip to content

Commit 23786e9

Browse files
committed
Move all pg_tde related tests into contrib/pg_tde
While these tests test our changes to pg_waldump they are quite easy to overlook right now and where exactly should we draw the line? These tests are not something we ever want to upstream and in the future when we figure out how we want to make sure pg_waldump works with encrypted WAL we likely will want to have the tests for that solution in the same folder as our other tests anyway.
1 parent bb000ef commit 23786e9

File tree

4 files changed

+60
-24
lines changed

4 files changed

+60
-24
lines changed

contrib/pg_tde/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ tap_tests = [
114114
't/011_unlogged_tables.pl',
115115
't/012_replication.pl',
116116
't/013_crash_recovery.pl',
117+
't/014_pg_waldump_basic.pl',
118+
't/015_pg_waldump_fullpage.pl',
117119
]
118120

119121
tests += {

src/bin/pg_waldump/t/003_basic_encrypted.pl renamed to contrib/pg_tde/t/014_pg_waldump_basic.pl

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727
$node->start;
2828

2929
$node->safe_psql('postgres', "CREATE EXTENSION IF NOT EXISTS pg_tde;");
30-
$node->safe_psql('postgres', "SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');");;
31-
$node->safe_psql('postgres', "SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');");
30+
$node->safe_psql('postgres',
31+
"SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');"
32+
);
33+
$node->safe_psql('postgres',
34+
"SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');"
35+
);
3236

3337
$node->append_conf(
3438
'postgresql.conf', q{
@@ -128,48 +132,74 @@
128132
[ 'pg_waldump', 'foo', 'bar' ],
129133
qr/error: could not locate WAL file "foo"/,
130134
'start file not found');
131-
command_like([ 'pg_waldump', '-k', $node->data_dir. '/pg_tde', $node->data_dir . '/pg_wal/' . $start_walfile ],
132-
qr/./, 'runs with start segment specified');
135+
command_like(
136+
[
137+
'pg_waldump', '-k',
138+
$node->data_dir . '/pg_tde',
139+
$node->data_dir . '/pg_wal/' . $start_walfile
140+
],
141+
qr/./,
142+
'runs with start segment specified');
133143
command_fails_like(
134-
[ 'pg_waldump', '-k', $node->data_dir. '/pg_tde', $node->data_dir . '/pg_wal/' . $start_walfile, 'bar' ],
144+
[
145+
'pg_waldump', '-k',
146+
$node->data_dir . '/pg_tde',
147+
$node->data_dir . '/pg_wal/' . $start_walfile, 'bar'
148+
],
135149
qr/error: could not open file "bar"/,
136150
'end file not found');
137151
command_like(
138152
[
139153
'pg_waldump',
140-
'-k', $node->data_dir. '/pg_tde',
154+
'-k',
155+
$node->data_dir . '/pg_tde',
141156
$node->data_dir . '/pg_wal/' . $start_walfile,
142157
$node->data_dir . '/pg_wal/' . $end_walfile
143158
],
144159
qr/./,
145160
'runs with start and end segment specified');
146161
command_fails_like(
147-
[ 'pg_waldump', '-p', $node->data_dir, '-k', $node->data_dir. '/pg_tde' ],
162+
[
163+
'pg_waldump', '-p', $node->data_dir, '-k',
164+
$node->data_dir . '/pg_tde'
165+
],
148166
qr/error: no start WAL location given/,
149167
'path option requires start location');
150168
command_like(
151169
[
152-
'pg_waldump', '-p', $node->data_dir, '--start',
153-
$start_lsn, '--end', $end_lsn,
154-
'-k', $node->data_dir. '/pg_tde'
170+
'pg_waldump', '-p',
171+
$node->data_dir, '--start',
172+
$start_lsn, '--end',
173+
$end_lsn, '-k',
174+
$node->data_dir . '/pg_tde'
155175
],
156176
qr/./,
157177
'runs with path option and start and end locations');
158178
command_fails_like(
159-
[ 'pg_waldump', '-k', $node->data_dir. '/pg_tde', '-p', $node->data_dir, '--start', $start_lsn ],
179+
[
180+
'pg_waldump', '-k',
181+
$node->data_dir . '/pg_tde', '-p',
182+
$node->data_dir, '--start',
183+
$start_lsn
184+
],
160185
qr/error: error in WAL record at/,
161186
'falling off the end of the WAL results in an error');
162187

163188
command_like(
164189
[
165-
'pg_waldump', '--quiet',
166-
'-k', $node->data_dir. '/pg_tde',
190+
'pg_waldump', '--quiet', '-k',
191+
$node->data_dir . '/pg_tde',
167192
$node->data_dir . '/pg_wal/' . $start_walfile
168193
],
169194
qr/^$/,
170195
'no output with --quiet option');
171196
command_fails_like(
172-
[ 'pg_waldump', '--quiet', '-k', $node->data_dir. '/pg_tde', '-p', $node->data_dir, '--start', $start_lsn ],
197+
[
198+
'pg_waldump', '--quiet',
199+
'-k', $node->data_dir . '/pg_tde',
200+
'-p', $node->data_dir,
201+
'--start', $start_lsn
202+
],
173203
qr/error: error in WAL record at/,
174204
'errors are shown with --quiet');
175205

@@ -187,9 +217,8 @@
187217
my (@cmd, $stdout, $stderr, $result);
188218

189219
@cmd = (
190-
'pg_waldump', '-k', $node->data_dir. '/pg_tde',
191-
'--start', $new_start,
192-
$node->data_dir . '/pg_wal/' . $start_walfile);
220+
'pg_waldump', '-k', $node->data_dir . '/pg_tde',
221+
'--start', $new_start, $node->data_dir . '/pg_wal/' . $start_walfile);
193222
$result = IPC::Run::run \@cmd, '>', \$stdout, '2>', \$stderr;
194223
ok($result, "runs with start segment and start LSN specified");
195224
like($stderr, qr/first record is after/, 'info message printed');
@@ -206,8 +235,11 @@ sub test_pg_waldump
206235
my (@cmd, $stdout, $stderr, $result, @lines);
207236

208237
@cmd = (
209-
'pg_waldump', '-k', $node->data_dir. '/pg_tde', '-p', $node->data_dir,
210-
'--start', $start_lsn, '--end', $end_lsn);
238+
'pg_waldump', '-k',
239+
$node->data_dir . '/pg_tde', '-p',
240+
$node->data_dir, '--start',
241+
$start_lsn, '--end',
242+
$end_lsn);
211243
push @cmd, @opts;
212244
$result = IPC::Run::run \@cmd, '>', \$stdout, '2>', \$stderr;
213245
ok($result, "pg_waldump @opts: runs ok");

src/bin/pg_waldump/t/004_save_fullpage_encrypted.pl renamed to contrib/pg_tde/t/015_pg_waldump_fullpage.pl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ sub get_block_lsn
4141
$node->start;
4242

4343
$node->safe_psql('postgres', "CREATE EXTENSION IF NOT EXISTS pg_tde;");
44-
$node->safe_psql('postgres', "SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');");;
45-
$node->safe_psql('postgres', "SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');");
44+
$node->safe_psql('postgres',
45+
"SELECT pg_tde_add_global_key_provider_file('file-keyring-wal','/tmp/pg_tde_test_keyring-wal.per');"
46+
);
47+
$node->safe_psql('postgres',
48+
"SELECT pg_tde_set_server_key_using_global_key_provider('server-key', 'file-keyring-wal');"
49+
);
4650

4751
$node->append_conf(
4852
'postgresql.conf', q{
@@ -84,7 +88,7 @@ sub get_block_lsn
8488
$node->command_ok(
8589
[
8690
'pg_waldump', '--quiet',
87-
'-k', $node->data_dir. '/pg_tde',
91+
'-k', $node->data_dir . '/pg_tde',
8892
'--save-fullpage', "$tmp_folder/raw",
8993
'--relation', $relation,
9094
$walfile

src/bin/pg_waldump/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ tests += {
4242
'tests': [
4343
't/001_basic.pl',
4444
't/002_save_fullpage.pl',
45-
't/003_basic_encrypted.pl',
46-
't/004_save_fullpage_encrypted.pl',
4745
],
4846
},
4947
}

0 commit comments

Comments
 (0)