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

Commit 858b4db

Browse files
committed
Improve TAP tests of pg_basebackup
This addresses some minor issues with the TAP tests of pg_basebackup: - Remove three duplicated tests used for incorrect option combinations. - Add more pattern checks for commands doomed to fail, to make sure that the error generated is the expected one. These are for tests related to the tablespace mapping and incorrect option combinations. - Fix the description of one test for the case of backup target versus format. Issues noticed while reviewing this area of the tests. Discussion: https://postgr.es/m/87bjvy50cs.fsf@wibble.ilmari.org
1 parent 172e6b3 commit 858b4db

File tree

1 file changed

+21
-38
lines changed

1 file changed

+21
-38
lines changed

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

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -324,53 +324,59 @@
324324
ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
325325
rmtree("$tempdir/tarbackup");
326326

327-
$node->command_fails(
327+
$node->command_fails_like(
328328
[
329329
@pg_basebackup_defs,
330330
'--pgdata' => "$tempdir/backup_foo",
331331
'--format' => 'plain',
332332
'--tablespace-mapping' => '=/foo'
333333
],
334+
qr/invalid tablespace mapping format/,
334335
'--tablespace-mapping with empty old directory fails');
335-
$node->command_fails(
336+
$node->command_fails_like(
336337
[
337338
@pg_basebackup_defs,
338339
'--pgdata' => "$tempdir/backup_foo",
339340
'--format' => 'plain',
340341
'--tablespace-mapping' => '/foo='
341342
],
343+
qr/invalid tablespace mapping format/,
342344
'--tablespace-mapping with empty new directory fails');
343-
$node->command_fails(
345+
$node->command_fails_like(
344346
[
345347
@pg_basebackup_defs,
346348
'--pgdata' => "$tempdir/backup_foo",
347349
'--format' => 'plain',
348350
'--tablespace-mapping' => '/foo=/bar=/baz'
349351
],
352+
qr/multiple "=" signs in tablespace mapping/,
350353
'--tablespace-mapping with multiple = fails');
351-
$node->command_fails(
354+
$node->command_fails_like(
352355
[
353356
@pg_basebackup_defs,
354357
'--pgdata' => "$tempdir/backup_foo",
355358
'--format' => 'plain',
356359
'--tablespace-mapping' => 'foo=/bar'
357360
],
361+
qr/old directory is not an absolute path in tablespace mapping/,
358362
'--tablespace-mapping with old directory not absolute fails');
359-
$node->command_fails(
363+
$node->command_fails_like(
360364
[
361365
@pg_basebackup_defs,
362366
'--pgdata' => "$tempdir/backup_foo",
363367
'--format' => 'plain',
364368
'--tablespace-mapping' => '/foo=bar'
365369
],
370+
qr/new directory is not an absolute path in tablespace mapping/,
366371
'--tablespace-mapping with new directory not absolute fails');
367-
$node->command_fails(
372+
$node->command_fails_like(
368373
[
369374
@pg_basebackup_defs,
370375
'--pgdata' => "$tempdir/backup_foo",
371376
'--format' => 'plain',
372377
'--tablespace-mapping' => 'foo'
373378
],
379+
qr/invalid tablespace mapping format/,
374380
'--tablespace-mapping with invalid format fails');
375381

376382
my $superlongname = "superlongname_" . ("x" x 100);
@@ -709,7 +715,7 @@
709715
'--format' => 'tar'
710716
],
711717
qr/cannot specify both format and backup target/,
712-
'backup target and output directory');
718+
'backup target and format');
713719
$node->command_ok(
714720
[
715721
@pg_basebackup_defs,
@@ -742,31 +748,34 @@
742748
'backup tar was created as non-superuser');
743749
rmtree("$tempdir/backuponserver");
744750

745-
$node->command_fails(
751+
$node->command_fails_like(
746752
[
747753
@pg_basebackup_defs,
748754
'--pgdata' => "$tempdir/backupxs_sl_fail",
749755
'--wal-method' => 'stream',
750756
'--slot' => 'slot0'
751757
],
758+
qr/replication slot "slot0" does not exist/,
752759
'pg_basebackup fails with nonexistent replication slot');
753760

754-
$node->command_fails(
761+
$node->command_fails_like(
755762
[
756763
@pg_basebackup_defs,
757764
'--pgdata' => "$tempdir/backupxs_slot",
758765
'--create-slot'
759766
],
767+
qr/--create-slot needs a slot to be specified using --slot/,
760768
'pg_basebackup --create-slot fails without slot name');
761769

762-
$node->command_fails(
770+
$node->command_fails_like(
763771
[
764772
@pg_basebackup_defs,
765773
'--pgdata' => "$tempdir/backupxs_slot",
766774
'--create-slot',
767775
'--slot' => 'slot0',
768776
'--no-slot'
769777
],
778+
qr/--no-slot cannot be used with slot name/,
770779
'pg_basebackup fails with --create-slot --slot --no-slot');
771780
$node->command_fails_like(
772781
[
@@ -785,33 +794,6 @@
785794
],
786795
'pg_basebackup --wal-method fetch runs');
787796

788-
$node->command_fails(
789-
[
790-
@pg_basebackup_defs,
791-
'--pgdata' => "$tempdir/backupxs_sl_fail",
792-
'--wal-method' => 'stream',
793-
'--slot' => 'slot0'
794-
],
795-
'pg_basebackup fails with nonexistent replication slot');
796-
797-
$node->command_fails(
798-
[
799-
@pg_basebackup_defs,
800-
'--pgdata' => "$tempdir/backupxs_slot",
801-
'--create-slot'
802-
],
803-
'pg_basebackup --create-slot fails without slot name');
804-
805-
$node->command_fails(
806-
[
807-
@pg_basebackup_defs,
808-
'--pgdata' => "$tempdir/backupxs_slot",
809-
'--create-slot',
810-
'--slot' => 'slot0',
811-
'--no-slot'
812-
],
813-
'pg_basebackup fails with --create-slot --slot --no-slot');
814-
815797
$node->command_ok(
816798
[
817799
@pg_basebackup_defs,
@@ -836,13 +818,14 @@
836818
'',
837819
'restart LSN of new slot is not null');
838820

839-
$node->command_fails(
821+
$node->command_fails_like(
840822
[
841823
@pg_basebackup_defs,
842824
'--pgdata' => "$tempdir/backupxs_slot1",
843825
'--create-slot',
844826
'--slot' => 'slot0'
845827
],
828+
qr/replication slot "slot0" already exists/,
846829
'pg_basebackup fails with --create-slot --slot and a previously existing slot'
847830
);
848831

0 commit comments

Comments
 (0)