Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0324297

Browse files
committed
Clean up intermetiate state in pg_basebackup tests
These tests accummulated almost a gigabyte of data during the test which was then removed at the end. Instead, remove output that's no longer needed between the individual tests, to keep the total disk usage down lower. Author: Michael Banck
1 parent f66c37b commit 0324297

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/bin/pg_basebackup/t/010_pg_basebackup.pl

+22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use Cwd;
44
use Config;
55
use File::Basename qw(basename dirname);
6+
use File::Path qw(rmtree);
67
use PostgresNode;
78
use TestLib;
89
use Test::More tests => 104;
@@ -135,17 +136,21 @@
135136
# Make sure existing backup_label was ignored.
136137
isnt(slurp_file("$tempdir/backup/backup_label"),
137138
'DONOTCOPY', 'existing backup_label not copied');
139+
rmtree("$tempdir/backup");
138140

139141
$node->command_ok(
140142
[ 'pg_basebackup', '-D', "$tempdir/backup2", '--waldir',
141143
"$tempdir/xlog2" ],
142144
'separate xlog directory');
143145
ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created');
144146
ok(-d "$tempdir/xlog2/", 'xlog directory was created');
147+
rmtree("$tempdir/backup2");
148+
rmtree("$tempdir/xlog2");
145149

146150
$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup", '-Ft' ],
147151
'tar format');
148152
ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
153+
rmtree("$tempdir/tarbackup");
149154

150155
$node->command_fails(
151156
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ],
@@ -212,6 +217,7 @@
212217
ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created');
213218
my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar";
214219
is(scalar(@tblspc_tars), 1, 'one tablespace tar was created');
220+
rmtree("$tempdir/tarbackup2");
215221

216222
# Create an unlogged table to test that forks other than init are not copied.
217223
$node->safe_psql('postgres',
@@ -281,6 +287,7 @@
281287

282288
ok( -d "$tempdir/backup1/pg_replslot",
283289
'pg_replslot symlink copied as directory');
290+
rmtree("$tempdir/backup1");
284291

285292
mkdir "$tempdir/tbl=spc2";
286293
$node->safe_psql('postgres', "DROP TABLE test1;");
@@ -295,6 +302,7 @@
295302
ok(-d "$tempdir/tbackup/tbl=spc2",
296303
'tablespace with = sign was relocated');
297304
$node->safe_psql('postgres', "DROP TABLESPACE tblspc2;");
305+
rmtree("$tempdir/backup3");
298306

299307
mkdir "$tempdir/$superlongname";
300308
$node->safe_psql('postgres',
@@ -303,12 +311,14 @@
303311
[ 'pg_basebackup', '-D', "$tempdir/tarbackup_l3", '-Ft' ],
304312
'pg_basebackup tar with long symlink target');
305313
$node->safe_psql('postgres', "DROP TABLESPACE tblspc3;");
314+
rmtree("$tempdir/tarbackup_l3");
306315
}
307316

308317
$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backupR", '-R' ],
309318
'pg_basebackup -R runs');
310319
ok(-f "$tempdir/backupR/recovery.conf", 'recovery.conf was created');
311320
my $recovery_conf = slurp_file "$tempdir/backupR/recovery.conf";
321+
rmtree("$tempdir/backupR");
312322

313323
my $port = $node->port;
314324
like(
@@ -325,26 +335,31 @@
325335
'pg_basebackup runs in default xlog mode');
326336
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxd/pg_wal")),
327337
'WAL files copied');
338+
rmtree("$tempdir/backupxd");
328339

329340
$node->command_ok(
330341
[ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ],
331342
'pg_basebackup -X fetch runs');
332343
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")),
333344
'WAL files copied');
345+
rmtree("$tempdir/backupxf");
334346
$node->command_ok(
335347
[ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ],
336348
'pg_basebackup -X stream runs');
337349
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxs/pg_wal")),
338350
'WAL files copied');
351+
rmtree("$tempdir/backupxs");
339352
$node->command_ok(
340353
[ 'pg_basebackup', '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ],
341354
'pg_basebackup -X stream runs in tar mode');
342355
ok(-f "$tempdir/backupxst/pg_wal.tar", "tar file was created");
356+
rmtree("$tempdir/backupxst");
343357
$node->command_ok(
344358
[ 'pg_basebackup', '-D',
345359
"$tempdir/backupnoslot", '-X',
346360
'stream', '--no-slot' ],
347361
'pg_basebackup -X stream runs with --no-slot');
362+
rmtree("$tempdir/backupnoslot");
348363

349364
$node->command_fails(
350365
[ 'pg_basebackup', '-D',
@@ -364,6 +379,7 @@
364379
$node->command_ok(
365380
[ 'pg_basebackup', '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0' ],
366381
'pg_basebackup -C runs');
382+
rmtree("$tempdir/backupxs_slot");
367383

368384
is($node->safe_psql('postgres', q{SELECT slot_name FROM pg_replication_slots WHERE slot_name = 'slot0'}),
369385
'slot0',
@@ -393,6 +409,7 @@
393409
q{SELECT restart_lsn FROM pg_replication_slots WHERE slot_name = 'slot1'}
394410
);
395411
like($lsn, qr!^0/[0-9A-Z]{7,8}$!, 'restart LSN of slot has advanced');
412+
rmtree("$tempdir/backupxs_sl");
396413

397414
$node->command_ok(
398415
[ 'pg_basebackup', '-D', "$tempdir/backupxs_sl_R", '-X',
@@ -405,6 +422,7 @@
405422

406423
my $checksum = $node->safe_psql('postgres', 'SHOW data_checksums;');
407424
is($checksum, 'on', 'checksums are enabled');
425+
rmtree("$tempdir/backupxs_sl_R");
408426

409427
# create tables to corrupt and get their relfilenodes
410428
my $file_corrupt1 = $node->safe_psql('postgres',
@@ -432,6 +450,7 @@
432450
[qr/^WARNING.*checksum verification failed/s],
433451
'pg_basebackup reports checksum mismatch'
434452
);
453+
rmtree("$tempdir/backup_corrupt");
435454

436455
# induce further corruption in 5 more blocks
437456
system_or_bail 'pg_ctl', '-D', $pgdata, 'stop';
@@ -450,6 +469,7 @@
450469
[qr/^WARNING.*further.*failures.*will.not.be.reported/s],
451470
'pg_basebackup does not report more than 5 checksum mismatches'
452471
);
472+
rmtree("$tempdir/backup_corrupt2");
453473

454474
# induce corruption in a second file
455475
system_or_bail 'pg_ctl', '-D', $pgdata, 'stop';
@@ -465,11 +485,13 @@
465485
[qr/^WARNING.*7 total checksum verification failures/s],
466486
'pg_basebackup correctly report the total number of checksum mismatches'
467487
);
488+
rmtree("$tempdir/backup_corrupt3");
468489

469490
# do not verify checksums, should return ok
470491
$node->command_ok(
471492
[ 'pg_basebackup', '-D', "$tempdir/backup_corrupt4", '-k' ],
472493
'pg_basebackup with -k does not report checksum mismatch');
494+
rmtree("$tempdir/backup_corrupt4");
473495

474496
$node->safe_psql('postgres', "DROP TABLE corrupt1;");
475497
$node->safe_psql('postgres', "DROP TABLE corrupt2;");

0 commit comments

Comments
 (0)