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

Commit 839f963

Browse files
committed
tests: Consistently use pg_basebackup -cfast --no-sync to accelerate tests.
Most tests invoking pg_basebackup themselves did not yet use -cfast, which makes pg_basebackup take considerably longer. The only reason this didn't cause the tests to take many minutes is that spread checkpoints only throttle when writing out a buffer and there aren't that many dirty buffers in the tests... Discussion: https://postgr.es/m/20220117195711.xx4qbxutrrlmo2dg@alap3.anarazel.de
1 parent c702d65 commit 839f963

File tree

6 files changed

+61
-55
lines changed

6 files changed

+61
-55
lines changed

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

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020

2121
my $node = PostgreSQL::Test::Cluster->new('main');
2222

23+
# For nearly all pg_basebackup invocations some options should be specified,
24+
# to keep test times reasonable. Using @pg_basebackup_defs as the first
25+
# element of the array passed to to IPC::Run interpolate the array (as it is
26+
# not a reference to an array)...
27+
my @pg_basebackup_defs = ('pg_basebackup', '--no-sync', '-cfast');
28+
29+
2330
# Set umask so test directories and files are created with default permissions
2431
umask(0077);
2532

@@ -43,7 +50,7 @@
4350
system_or_bail 'pg_ctl', '-D', $pgdata, 'reload';
4451

4552
$node->command_fails(
46-
[ 'pg_basebackup', '-D', "$tempdir/backup" ],
53+
[ @pg_basebackup_defs, '-D', "$tempdir/backup" ],
4754
'pg_basebackup fails because of WAL configuration');
4855

4956
ok(!-d "$tempdir/backup", 'backup directory was cleaned up');
@@ -54,7 +61,7 @@
5461
or BAIL_OUT("unable to create $tempdir/backup");
5562
append_to_file("$tempdir/backup/dir-not-empty.txt", "Some data");
5663

57-
$node->command_fails([ 'pg_basebackup', '-D', "$tempdir/backup", '-n' ],
64+
$node->command_fails([ @pg_basebackup_defs, '-D', "$tempdir/backup", '-n' ],
5865
'failing run with no-clean option');
5966

6067
ok(-d "$tempdir/backup", 'backup directory was created and left behind');
@@ -105,7 +112,7 @@
105112
}
106113

107114
# Run base backup.
108-
$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backup", '-X', 'none' ],
115+
$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/backup", '-X', 'none' ],
109116
'pg_basebackup runs');
110117
ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
111118
ok(-f "$tempdir/backup/backup_manifest", 'backup manifest included');
@@ -165,9 +172,9 @@
165172

166173
$node->command_ok(
167174
[
168-
'pg_basebackup', '-D',
169-
"$tempdir/backup2", '--no-manifest',
170-
'--waldir', "$tempdir/xlog2"
175+
@pg_basebackup_defs, '-D',
176+
"$tempdir/backup2", '--no-manifest',
177+
'--waldir', "$tempdir/xlog2"
171178
],
172179
'separate xlog directory');
173180
ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created');
@@ -176,31 +183,31 @@
176183
rmtree("$tempdir/backup2");
177184
rmtree("$tempdir/xlog2");
178185

179-
$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup", '-Ft' ],
186+
$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/tarbackup", '-Ft' ],
180187
'tar format');
181188
ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
182189
rmtree("$tempdir/tarbackup");
183190

184191
$node->command_fails(
185-
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ],
192+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ],
186193
'-T with empty old directory fails');
187194
$node->command_fails(
188-
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=" ],
195+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=" ],
189196
'-T with empty new directory fails');
190197
$node->command_fails(
191198
[
192-
'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp',
199+
@pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp',
193200
"-T/foo=/bar=/baz"
194201
],
195202
'-T with multiple = fails');
196203
$node->command_fails(
197-
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo=/bar" ],
204+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo=/bar" ],
198205
'-T with old directory not absolute fails');
199206
$node->command_fails(
200-
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=bar" ],
207+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=bar" ],
201208
'-T with new directory not absolute fails');
202209
$node->command_fails(
203-
[ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo" ],
210+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo" ],
204211
'-T with invalid format fails');
205212

206213
# Tar format doesn't support filenames longer than 100 bytes.
@@ -211,7 +218,7 @@
211218
or die "unable to create file $superlongpath";
212219
close $file;
213220
$node->command_fails(
214-
[ 'pg_basebackup', '-D', "$tempdir/tarbackup_l1", '-Ft' ],
221+
[ @pg_basebackup_defs, '-D', "$tempdir/tarbackup_l1", '-Ft' ],
215222
'pg_basebackup tar with long name fails');
216223
unlink "$pgdata/$superlongname";
217224

@@ -329,14 +336,14 @@
329336
}
330337

331338
$node->command_fails(
332-
[ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ],
339+
[ @pg_basebackup_defs, '-D', "$tempdir/backup1", '-Fp' ],
333340
'plain format with tablespaces fails without tablespace mapping');
334341

335342
$node->command_ok(
336343
[
337-
'pg_basebackup', '-D',
338-
"$tempdir/backup1", '-Fp',
339-
"-T$realTsDir=$real_tempdir/tbackup/tblspc1"
344+
@pg_basebackup_defs, '-D',
345+
"$tempdir/backup1", '-Fp',
346+
"-T$realTsDir=$real_tempdir/tbackup/tblspc1",
340347
],
341348
'plain format with tablespaces succeeds with tablespace mapping');
342349
ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated');
@@ -404,9 +411,9 @@
404411
$realTsDir =~ s/=/\\=/;
405412
$node->command_ok(
406413
[
407-
'pg_basebackup', '-D',
408-
"$tempdir/backup3", '-Fp',
409-
"-T$realTsDir=$real_tempdir/tbackup/tbl\\=spc2"
414+
@pg_basebackup_defs, '-D',
415+
"$tempdir/backup3", '-Fp',
416+
"-T$realTsDir=$real_tempdir/tbackup/tbl\\=spc2",
410417
],
411418
'mapping tablespace with = sign in path');
412419
ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated');
@@ -417,12 +424,12 @@
417424
$realTsDir = "$real_sys_tempdir/$superlongname";
418425
$node->safe_psql('postgres',
419426
"CREATE TABLESPACE tblspc3 LOCATION '$realTsDir';");
420-
$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup_l3", '-Ft' ],
427+
$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/tarbackup_l3", '-Ft' ],
421428
'pg_basebackup tar with long symlink target');
422429
$node->safe_psql('postgres', "DROP TABLESPACE tblspc3;");
423430
rmtree("$tempdir/tarbackup_l3");
424431

425-
$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backupR", '-R' ],
432+
$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/backupR", '-R' ],
426433
'pg_basebackup -R runs');
427434
ok(-f "$tempdir/backupR/postgresql.auto.conf", 'postgresql.auto.conf exists');
428435
ok(-f "$tempdir/backupR/standby.signal", 'standby.signal was created');
@@ -436,32 +443,32 @@
436443
'postgresql.auto.conf sets primary_conninfo');
437444

438445
$node->command_ok(
439-
[ 'pg_basebackup', '-D', "$tempdir/backupxd" ],
446+
[ @pg_basebackup_defs, '-D', "$tempdir/backupxd" ],
440447
'pg_basebackup runs in default xlog mode');
441448
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxd/pg_wal")),
442449
'WAL files copied');
443450
rmtree("$tempdir/backupxd");
444451

445452
$node->command_ok(
446-
[ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ],
453+
[ @pg_basebackup_defs, '-D', "$tempdir/backupxf", '-X', 'fetch' ],
447454
'pg_basebackup -X fetch runs');
448455
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")),
449456
'WAL files copied');
450457
rmtree("$tempdir/backupxf");
451458
$node->command_ok(
452-
[ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ],
459+
[ @pg_basebackup_defs, '-D', "$tempdir/backupxs", '-X', 'stream' ],
453460
'pg_basebackup -X stream runs');
454461
ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxs/pg_wal")),
455462
'WAL files copied');
456463
rmtree("$tempdir/backupxs");
457464
$node->command_ok(
458-
[ 'pg_basebackup', '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ],
465+
[ @pg_basebackup_defs, '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ],
459466
'pg_basebackup -X stream runs in tar mode');
460467
ok(-f "$tempdir/backupxst/pg_wal.tar", "tar file was created");
461468
rmtree("$tempdir/backupxst");
462469
$node->command_ok(
463470
[
464-
'pg_basebackup', '-D',
471+
@pg_basebackup_defs, '-D',
465472
"$tempdir/backupnoslot", '-X',
466473
'stream', '--no-slot'
467474
],
@@ -470,28 +477,28 @@
470477

471478
$node->command_fails(
472479
[
473-
'pg_basebackup', '-D',
480+
@pg_basebackup_defs, '-D',
474481
"$tempdir/backupxs_sl_fail", '-X',
475482
'stream', '-S',
476483
'slot0'
477484
],
478485
'pg_basebackup fails with nonexistent replication slot');
479486

480487
$node->command_fails(
481-
[ 'pg_basebackup', '-D', "$tempdir/backupxs_slot", '-C' ],
488+
[ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot", '-C' ],
482489
'pg_basebackup -C fails without slot name');
483490

484491
$node->command_fails(
485492
[
486-
'pg_basebackup', '-D',
493+
@pg_basebackup_defs, '-D',
487494
"$tempdir/backupxs_slot", '-C',
488495
'-S', 'slot0',
489496
'--no-slot'
490497
],
491498
'pg_basebackup fails with -C -S --no-slot');
492499

493500
$node->command_ok(
494-
[ 'pg_basebackup', '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0' ],
501+
[ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0' ],
495502
'pg_basebackup -C runs');
496503
rmtree("$tempdir/backupxs_slot");
497504

@@ -510,7 +517,7 @@
510517
'restart LSN of new slot is not null');
511518

512519
$node->command_fails(
513-
[ 'pg_basebackup', '-D', "$tempdir/backupxs_slot1", '-C', '-S', 'slot0' ],
520+
[ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot1", '-C', '-S', 'slot0' ],
514521
'pg_basebackup fails with -C -S and a previously existing slot');
515522

516523
$node->safe_psql('postgres',
@@ -520,12 +527,12 @@
520527
);
521528
is($lsn, '', 'restart LSN of new slot is null');
522529
$node->command_fails(
523-
[ 'pg_basebackup', '-D', "$tempdir/fail", '-S', 'slot1', '-X', 'none' ],
530+
[ @pg_basebackup_defs, '-D', "$tempdir/fail", '-S', 'slot1', '-X', 'none' ],
524531
'pg_basebackup with replication slot fails without WAL streaming');
525532
$node->command_ok(
526533
[
527-
'pg_basebackup', '-D', "$tempdir/backupxs_sl", '-X',
528-
'stream', '-S', 'slot1'
534+
@pg_basebackup_defs, '-D', "$tempdir/backupxs_sl", '-X',
535+
'stream', '-S', 'slot1'
529536
],
530537
'pg_basebackup -X stream with replication slot runs');
531538
$lsn = $node->safe_psql('postgres',
@@ -536,8 +543,8 @@
536543

537544
$node->command_ok(
538545
[
539-
'pg_basebackup', '-D', "$tempdir/backupxs_sl_R", '-X',
540-
'stream', '-S', 'slot1', '-R'
546+
@pg_basebackup_defs, '-D', "$tempdir/backupxs_sl_R", '-X',
547+
'stream', '-S', 'slot1', '-R',
541548
],
542549
'pg_basebackup with replication slot and -R runs');
543550
like(
@@ -570,7 +577,7 @@
570577
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
571578

572579
$node->command_checks_all(
573-
[ 'pg_basebackup', '-D', "$tempdir/backup_corrupt" ],
580+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt" ],
574581
1,
575582
[qr{^$}],
576583
[qr/^WARNING.*checksum verification failed/s],
@@ -590,7 +597,7 @@
590597
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
591598

592599
$node->command_checks_all(
593-
[ 'pg_basebackup', '-D', "$tempdir/backup_corrupt2" ],
600+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt2" ],
594601
1,
595602
[qr{^$}],
596603
[qr/^WARNING.*further.*failures.*will.not.be.reported/s],
@@ -606,7 +613,7 @@
606613
system_or_bail 'pg_ctl', '-D', $pgdata, 'start';
607614

608615
$node->command_checks_all(
609-
[ 'pg_basebackup', '-D', "$tempdir/backup_corrupt3" ],
616+
[ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt3" ],
610617
1,
611618
[qr{^$}],
612619
[qr/^WARNING.*7 total checksum verification failures/s],
@@ -616,8 +623,8 @@
616623
# do not verify checksums, should return ok
617624
$node->command_ok(
618625
[
619-
'pg_basebackup', '-D',
620-
"$tempdir/backup_corrupt4", '--no-verify-checksums'
626+
@pg_basebackup_defs, '-D',
627+
"$tempdir/backup_corrupt4", '--no-verify-checksums',
621628
],
622629
'pg_basebackup with -k does not report checksum mismatch');
623630
rmtree("$tempdir/backup_corrupt4");
@@ -635,18 +642,17 @@
635642

636643
$node->command_ok(
637644
[
638-
'pg_basebackup', '-D',
645+
@pg_basebackup_defs, '-D',
639646
"$tempdir/backup_gzip", '--compress',
640-
'1', '--no-sync',
641-
'--format', 't'
647+
'1', '--format',
648+
't'
642649
],
643650
'pg_basebackup with --compress');
644651
$node->command_ok(
645652
[
646-
'pg_basebackup', '-D',
653+
@pg_basebackup_defs, '-D',
647654
"$tempdir/backup_gzip2", '--gzip',
648-
'--no-sync', '--format',
649-
't'
655+
'--format', 't'
650656
],
651657
'pg_basebackup with --gzip');
652658

src/bin/pg_verifybackup/t/002_algorithm.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
my $backup_path = $primary->backup_dir . '/' . $algorithm;
2222
my @backup = (
2323
'pg_basebackup', '-D', $backup_path,
24-
'--manifest-checksums', $algorithm, '--no-sync');
24+
'--manifest-checksums', $algorithm, '--no-sync', '-cfast');
2525
my @verify = ('pg_verifybackup', '-e', $backup_path);
2626

2727
# A backup with a bogus algorithm should fail.

src/bin/pg_verifybackup/t/003_corruption.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
local $ENV{MSYS2_ARG_CONV_EXCL} = $source_ts_prefix;
115115
$primary->command_ok(
116116
[
117-
'pg_basebackup', '-D', $backup_path, '--no-sync',
117+
'pg_basebackup', '-D', $backup_path, '--no-sync', '-cfast',
118118
'-T', "${source_ts_path}=${backup_ts_path}"
119119
],
120120
"base backup ok");

src/bin/pg_verifybackup/t/004_options.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$primary->init(allows_streaming => 1);
1818
$primary->start;
1919
my $backup_path = $primary->backup_dir . '/test_options';
20-
$primary->command_ok([ 'pg_basebackup', '-D', $backup_path, '--no-sync' ],
20+
$primary->command_ok([ 'pg_basebackup', '-D', $backup_path, '--no-sync', '-cfast' ],
2121
"base backup ok");
2222

2323
# Verify that pg_verifybackup -q succeeds and produces no output.

src/bin/pg_verifybackup/t/006_encoding.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[
2020
'pg_basebackup', '-D',
2121
$backup_path, '--no-sync',
22-
'--manifest-force-encode'
22+
'-cfast', '--manifest-force-encode'
2323
],
2424
"backup ok with forced hex encoding");
2525

src/bin/pg_verifybackup/t/007_wal.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$primary->init(allows_streaming => 1);
1818
$primary->start;
1919
my $backup_path = $primary->backup_dir . '/test_wal';
20-
$primary->command_ok([ 'pg_basebackup', '-D', $backup_path, '--no-sync' ],
20+
$primary->command_ok([ 'pg_basebackup', '-D', $backup_path, '--no-sync', '-cfast' ],
2121
"base backup ok");
2222

2323
# Rename pg_wal.
@@ -71,7 +71,7 @@
7171
my $backup_path2 = $primary->backup_dir . '/test_tli';
7272
# The base backup run below does a checkpoint, that removes the first segment
7373
# of the current timeline.
74-
$primary->command_ok([ 'pg_basebackup', '-D', $backup_path2, '--no-sync' ],
74+
$primary->command_ok([ 'pg_basebackup', '-D', $backup_path2, '--no-sync', '-cfast' ],
7575
"base backup 2 ok");
7676
command_ok(
7777
[ 'pg_verifybackup', $backup_path2 ],

0 commit comments

Comments
 (0)