|
20 | 20 |
|
21 | 21 | my $node = PostgreSQL::Test::Cluster->new('main'); |
22 | 22 |
|
| 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 | + |
23 | 30 | # Set umask so test directories and files are created with default permissions |
24 | 31 | umask(0077); |
25 | 32 |
|
|
43 | 50 | system_or_bail 'pg_ctl', '-D', $pgdata, 'reload'; |
44 | 51 |
|
45 | 52 | $node->command_fails( |
46 | | - [ 'pg_basebackup', '-D', "$tempdir/backup" ], |
| 53 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup" ], |
47 | 54 | 'pg_basebackup fails because of WAL configuration'); |
48 | 55 |
|
49 | 56 | ok(!-d "$tempdir/backup", 'backup directory was cleaned up'); |
|
54 | 61 | or BAIL_OUT("unable to create $tempdir/backup"); |
55 | 62 | append_to_file("$tempdir/backup/dir-not-empty.txt", "Some data"); |
56 | 63 |
|
57 | | -$node->command_fails([ 'pg_basebackup', '-D', "$tempdir/backup", '-n' ], |
| 64 | +$node->command_fails([ @pg_basebackup_defs, '-D', "$tempdir/backup", '-n' ], |
58 | 65 | 'failing run with no-clean option'); |
59 | 66 |
|
60 | 67 | ok(-d "$tempdir/backup", 'backup directory was created and left behind'); |
|
105 | 112 | } |
106 | 113 |
|
107 | 114 | # 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' ], |
109 | 116 | 'pg_basebackup runs'); |
110 | 117 | ok(-f "$tempdir/backup/PG_VERSION", 'backup was created'); |
111 | 118 | ok(-f "$tempdir/backup/backup_manifest", 'backup manifest included'); |
|
165 | 172 |
|
166 | 173 | $node->command_ok( |
167 | 174 | [ |
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" |
171 | 178 | ], |
172 | 179 | 'separate xlog directory'); |
173 | 180 | ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created'); |
|
176 | 183 | rmtree("$tempdir/backup2"); |
177 | 184 | rmtree("$tempdir/xlog2"); |
178 | 185 |
|
179 | | -$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup", '-Ft' ], |
| 186 | +$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/tarbackup", '-Ft' ], |
180 | 187 | 'tar format'); |
181 | 188 | ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created'); |
182 | 189 | rmtree("$tempdir/tarbackup"); |
183 | 190 |
|
184 | 191 | $node->command_fails( |
185 | | - [ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ], |
| 192 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ], |
186 | 193 | '-T with empty old directory fails'); |
187 | 194 | $node->command_fails( |
188 | | - [ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=" ], |
| 195 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-T/foo=" ], |
189 | 196 | '-T with empty new directory fails'); |
190 | 197 | $node->command_fails( |
191 | 198 | [ |
192 | | - 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', |
| 199 | + @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', |
193 | 200 | "-T/foo=/bar=/baz" |
194 | 201 | ], |
195 | 202 | '-T with multiple = fails'); |
196 | 203 | $node->command_fails( |
197 | | - [ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo=/bar" ], |
| 204 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo=/bar" ], |
198 | 205 | '-T with old directory not absolute fails'); |
199 | 206 | $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" ], |
201 | 208 | '-T with new directory not absolute fails'); |
202 | 209 | $node->command_fails( |
203 | | - [ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo" ], |
| 210 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup_foo", '-Fp', "-Tfoo" ], |
204 | 211 | '-T with invalid format fails'); |
205 | 212 |
|
206 | 213 | # Tar format doesn't support filenames longer than 100 bytes. |
|
211 | 218 | or die "unable to create file $superlongpath"; |
212 | 219 | close $file; |
213 | 220 | $node->command_fails( |
214 | | - [ 'pg_basebackup', '-D', "$tempdir/tarbackup_l1", '-Ft' ], |
| 221 | + [ @pg_basebackup_defs, '-D', "$tempdir/tarbackup_l1", '-Ft' ], |
215 | 222 | 'pg_basebackup tar with long name fails'); |
216 | 223 | unlink "$pgdata/$superlongname"; |
217 | 224 |
|
|
329 | 336 | } |
330 | 337 |
|
331 | 338 | $node->command_fails( |
332 | | - [ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ], |
| 339 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup1", '-Fp' ], |
333 | 340 | 'plain format with tablespaces fails without tablespace mapping'); |
334 | 341 |
|
335 | 342 | $node->command_ok( |
336 | 343 | [ |
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", |
340 | 347 | ], |
341 | 348 | 'plain format with tablespaces succeeds with tablespace mapping'); |
342 | 349 | ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated'); |
|
404 | 411 | $realTsDir =~ s/=/\\=/; |
405 | 412 | $node->command_ok( |
406 | 413 | [ |
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", |
410 | 417 | ], |
411 | 418 | 'mapping tablespace with = sign in path'); |
412 | 419 | ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated'); |
|
417 | 424 | $realTsDir = "$real_sys_tempdir/$superlongname"; |
418 | 425 | $node->safe_psql('postgres', |
419 | 426 | "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' ], |
421 | 428 | 'pg_basebackup tar with long symlink target'); |
422 | 429 | $node->safe_psql('postgres', "DROP TABLESPACE tblspc3;"); |
423 | 430 | rmtree("$tempdir/tarbackup_l3"); |
424 | 431 |
|
425 | | -$node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backupR", '-R' ], |
| 432 | +$node->command_ok([ @pg_basebackup_defs, '-D', "$tempdir/backupR", '-R' ], |
426 | 433 | 'pg_basebackup -R runs'); |
427 | 434 | ok(-f "$tempdir/backupR/postgresql.auto.conf", 'postgresql.auto.conf exists'); |
428 | 435 | ok(-f "$tempdir/backupR/standby.signal", 'standby.signal was created'); |
|
436 | 443 | 'postgresql.auto.conf sets primary_conninfo'); |
437 | 444 |
|
438 | 445 | $node->command_ok( |
439 | | - [ 'pg_basebackup', '-D', "$tempdir/backupxd" ], |
| 446 | + [ @pg_basebackup_defs, '-D', "$tempdir/backupxd" ], |
440 | 447 | 'pg_basebackup runs in default xlog mode'); |
441 | 448 | ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxd/pg_wal")), |
442 | 449 | 'WAL files copied'); |
443 | 450 | rmtree("$tempdir/backupxd"); |
444 | 451 |
|
445 | 452 | $node->command_ok( |
446 | | - [ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ], |
| 453 | + [ @pg_basebackup_defs, '-D', "$tempdir/backupxf", '-X', 'fetch' ], |
447 | 454 | 'pg_basebackup -X fetch runs'); |
448 | 455 | ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")), |
449 | 456 | 'WAL files copied'); |
450 | 457 | rmtree("$tempdir/backupxf"); |
451 | 458 | $node->command_ok( |
452 | | - [ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ], |
| 459 | + [ @pg_basebackup_defs, '-D', "$tempdir/backupxs", '-X', 'stream' ], |
453 | 460 | 'pg_basebackup -X stream runs'); |
454 | 461 | ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxs/pg_wal")), |
455 | 462 | 'WAL files copied'); |
456 | 463 | rmtree("$tempdir/backupxs"); |
457 | 464 | $node->command_ok( |
458 | | - [ 'pg_basebackup', '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ], |
| 465 | + [ @pg_basebackup_defs, '-D', "$tempdir/backupxst", '-X', 'stream', '-Ft' ], |
459 | 466 | 'pg_basebackup -X stream runs in tar mode'); |
460 | 467 | ok(-f "$tempdir/backupxst/pg_wal.tar", "tar file was created"); |
461 | 468 | rmtree("$tempdir/backupxst"); |
462 | 469 | $node->command_ok( |
463 | 470 | [ |
464 | | - 'pg_basebackup', '-D', |
| 471 | + @pg_basebackup_defs, '-D', |
465 | 472 | "$tempdir/backupnoslot", '-X', |
466 | 473 | 'stream', '--no-slot' |
467 | 474 | ], |
|
470 | 477 |
|
471 | 478 | $node->command_fails( |
472 | 479 | [ |
473 | | - 'pg_basebackup', '-D', |
| 480 | + @pg_basebackup_defs, '-D', |
474 | 481 | "$tempdir/backupxs_sl_fail", '-X', |
475 | 482 | 'stream', '-S', |
476 | 483 | 'slot0' |
477 | 484 | ], |
478 | 485 | 'pg_basebackup fails with nonexistent replication slot'); |
479 | 486 |
|
480 | 487 | $node->command_fails( |
481 | | - [ 'pg_basebackup', '-D', "$tempdir/backupxs_slot", '-C' ], |
| 488 | + [ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot", '-C' ], |
482 | 489 | 'pg_basebackup -C fails without slot name'); |
483 | 490 |
|
484 | 491 | $node->command_fails( |
485 | 492 | [ |
486 | | - 'pg_basebackup', '-D', |
| 493 | + @pg_basebackup_defs, '-D', |
487 | 494 | "$tempdir/backupxs_slot", '-C', |
488 | 495 | '-S', 'slot0', |
489 | 496 | '--no-slot' |
490 | 497 | ], |
491 | 498 | 'pg_basebackup fails with -C -S --no-slot'); |
492 | 499 |
|
493 | 500 | $node->command_ok( |
494 | | - [ 'pg_basebackup', '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0' ], |
| 501 | + [ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot", '-C', '-S', 'slot0' ], |
495 | 502 | 'pg_basebackup -C runs'); |
496 | 503 | rmtree("$tempdir/backupxs_slot"); |
497 | 504 |
|
|
510 | 517 | 'restart LSN of new slot is not null'); |
511 | 518 |
|
512 | 519 | $node->command_fails( |
513 | | - [ 'pg_basebackup', '-D', "$tempdir/backupxs_slot1", '-C', '-S', 'slot0' ], |
| 520 | + [ @pg_basebackup_defs, '-D', "$tempdir/backupxs_slot1", '-C', '-S', 'slot0' ], |
514 | 521 | 'pg_basebackup fails with -C -S and a previously existing slot'); |
515 | 522 |
|
516 | 523 | $node->safe_psql('postgres', |
|
520 | 527 | ); |
521 | 528 | is($lsn, '', 'restart LSN of new slot is null'); |
522 | 529 | $node->command_fails( |
523 | | - [ 'pg_basebackup', '-D', "$tempdir/fail", '-S', 'slot1', '-X', 'none' ], |
| 530 | + [ @pg_basebackup_defs, '-D', "$tempdir/fail", '-S', 'slot1', '-X', 'none' ], |
524 | 531 | 'pg_basebackup with replication slot fails without WAL streaming'); |
525 | 532 | $node->command_ok( |
526 | 533 | [ |
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' |
529 | 536 | ], |
530 | 537 | 'pg_basebackup -X stream with replication slot runs'); |
531 | 538 | $lsn = $node->safe_psql('postgres', |
|
536 | 543 |
|
537 | 544 | $node->command_ok( |
538 | 545 | [ |
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', |
541 | 548 | ], |
542 | 549 | 'pg_basebackup with replication slot and -R runs'); |
543 | 550 | like( |
|
570 | 577 | system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; |
571 | 578 |
|
572 | 579 | $node->command_checks_all( |
573 | | - [ 'pg_basebackup', '-D', "$tempdir/backup_corrupt" ], |
| 580 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt" ], |
574 | 581 | 1, |
575 | 582 | [qr{^$}], |
576 | 583 | [qr/^WARNING.*checksum verification failed/s], |
|
590 | 597 | system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; |
591 | 598 |
|
592 | 599 | $node->command_checks_all( |
593 | | - [ 'pg_basebackup', '-D', "$tempdir/backup_corrupt2" ], |
| 600 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt2" ], |
594 | 601 | 1, |
595 | 602 | [qr{^$}], |
596 | 603 | [qr/^WARNING.*further.*failures.*will.not.be.reported/s], |
|
606 | 613 | system_or_bail 'pg_ctl', '-D', $pgdata, 'start'; |
607 | 614 |
|
608 | 615 | $node->command_checks_all( |
609 | | - [ 'pg_basebackup', '-D', "$tempdir/backup_corrupt3" ], |
| 616 | + [ @pg_basebackup_defs, '-D', "$tempdir/backup_corrupt3" ], |
610 | 617 | 1, |
611 | 618 | [qr{^$}], |
612 | 619 | [qr/^WARNING.*7 total checksum verification failures/s], |
|
616 | 623 | # do not verify checksums, should return ok |
617 | 624 | $node->command_ok( |
618 | 625 | [ |
619 | | - 'pg_basebackup', '-D', |
620 | | - "$tempdir/backup_corrupt4", '--no-verify-checksums' |
| 626 | + @pg_basebackup_defs, '-D', |
| 627 | + "$tempdir/backup_corrupt4", '--no-verify-checksums', |
621 | 628 | ], |
622 | 629 | 'pg_basebackup with -k does not report checksum mismatch'); |
623 | 630 | rmtree("$tempdir/backup_corrupt4"); |
|
635 | 642 |
|
636 | 643 | $node->command_ok( |
637 | 644 | [ |
638 | | - 'pg_basebackup', '-D', |
| 645 | + @pg_basebackup_defs, '-D', |
639 | 646 | "$tempdir/backup_gzip", '--compress', |
640 | | - '1', '--no-sync', |
641 | | - '--format', 't' |
| 647 | + '1', '--format', |
| 648 | + 't' |
642 | 649 | ], |
643 | 650 | 'pg_basebackup with --compress'); |
644 | 651 | $node->command_ok( |
645 | 652 | [ |
646 | | - 'pg_basebackup', '-D', |
| 653 | + @pg_basebackup_defs, '-D', |
647 | 654 | "$tempdir/backup_gzip2", '--gzip', |
648 | | - '--no-sync', '--format', |
649 | | - 't' |
| 655 | + '--format', 't' |
650 | 656 | ], |
651 | 657 | 'pg_basebackup with --gzip'); |
652 | 658 |
|
|
0 commit comments