|
25 | 25 | close BADCHARS;
|
26 | 26 | }
|
27 | 27 |
|
28 |
| -open HBA, ">>$tempdir/pgdata/pg_hba.conf"; |
29 |
| -print HBA "local replication all trust\n"; |
30 |
| -print HBA "host replication all 127.0.0.1/32 trust\n"; |
31 |
| -print HBA "host replication all ::1/128 trust\n"; |
32 |
| -close HBA; |
| 28 | +configure_hba_for_replication "$tempdir/pgdata"; |
33 | 29 | system_or_bail 'pg_ctl', '-D', "$tempdir/pgdata", 'reload';
|
34 | 30 |
|
35 | 31 | command_fails(
|
|
57 | 53 | 'tar format');
|
58 | 54 | ok(-f "$tempdir/tarbackup/base.tar", 'backup tar was created');
|
59 | 55 |
|
60 |
| -# Create a temporary directory in the system location and symlink it |
61 |
| -# to our physical temp location. That way we can use shorter names |
62 |
| -# for the tablespace directories, which hopefully won't run afoul of |
63 |
| -# the 99 character length limit. |
64 |
| -my $shorter_tempdir = tempdir_short . "/tempdir"; |
65 |
| -symlink "$tempdir", $shorter_tempdir; |
66 |
| - |
67 |
| -mkdir "$tempdir/tblspc1"; |
68 |
| -psql 'postgres', "CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';"; |
69 |
| -psql 'postgres', "CREATE TABLE test1 (a int) TABLESPACE tblspc1;"; |
70 |
| -command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup2", '-Ft' ], |
71 |
| - 'tar format with tablespaces'); |
72 |
| -ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created'); |
73 |
| -my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar"; |
74 |
| -is(scalar(@tblspc_tars), 1, 'one tablespace tar was created'); |
75 |
| - |
76 |
| -command_fails( |
77 |
| - [ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ], |
78 |
| - 'plain format with tablespaces fails without tablespace mapping'); |
79 |
| - |
80 |
| -command_ok( |
81 |
| - [ 'pg_basebackup', '-D', |
82 |
| - "$tempdir/backup1", '-Fp', |
83 |
| - "-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ], |
84 |
| - 'plain format with tablespaces succeeds with tablespace mapping'); |
85 |
| -ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated'); |
86 |
| -opendir(my $dh, "$tempdir/pgdata/pg_tblspc") or die; |
87 |
| -ok( ( grep |
88 |
| - { |
89 |
| - -l "$tempdir/backup1/pg_tblspc/$_" |
90 |
| - and readlink "$tempdir/backup1/pg_tblspc/$_" eq |
91 |
| - "$tempdir/tbackup/tblspc1" |
92 |
| - } readdir($dh)), |
93 |
| - "tablespace symlink was updated"); |
94 |
| -closedir $dh; |
95 |
| - |
96 |
| -mkdir "$tempdir/tbl=spc2"; |
97 |
| -psql 'postgres', "DROP TABLE test1;"; |
98 |
| -psql 'postgres', "DROP TABLESPACE tblspc1;"; |
99 |
| -psql 'postgres', "CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';"; |
100 |
| -command_ok( |
101 |
| - [ 'pg_basebackup', '-D', |
102 |
| - "$tempdir/backup3", '-Fp', |
103 |
| - "-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ], |
104 |
| - 'mapping tablespace with = sign in path'); |
105 |
| -ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated'); |
106 |
| - |
107 |
| -psql 'postgres', "DROP TABLESPACE tblspc2;"; |
| 56 | +# The following tests test symlinks. Windows doesn't have symlinks, so |
| 57 | +# skip on Windows. |
| 58 | +SKIP: { |
| 59 | + # Create a temporary directory in the system location and symlink it |
| 60 | + # to our physical temp location. That way we can use shorter names |
| 61 | + # for the tablespace directories, which hopefully won't run afoul of |
| 62 | + # the 99 character length limit. |
| 63 | + skip "symlinks not supported on Windows", 9 if ($windows_os); |
| 64 | + |
| 65 | + my $shorter_tempdir = tempdir_short . "/tempdir"; |
| 66 | + symlink "$tempdir", $shorter_tempdir; |
| 67 | + |
| 68 | + mkdir "$tempdir/tblspc1"; |
| 69 | + psql 'postgres', "CREATE TABLESPACE tblspc1 LOCATION '$shorter_tempdir/tblspc1';"; |
| 70 | + psql 'postgres', "CREATE TABLE test1 (a int) TABLESPACE tblspc1;"; |
| 71 | + command_ok([ 'pg_basebackup', '-D', "$tempdir/tarbackup2", '-Ft' ], |
| 72 | + 'tar format with tablespaces'); |
| 73 | + ok(-f "$tempdir/tarbackup2/base.tar", 'backup tar was created'); |
| 74 | + my @tblspc_tars = glob "$tempdir/tarbackup2/[0-9]*.tar"; |
| 75 | + is(scalar(@tblspc_tars), 1, 'one tablespace tar was created'); |
| 76 | + |
| 77 | + command_fails( |
| 78 | + [ 'pg_basebackup', '-D', "$tempdir/backup1", '-Fp' ], |
| 79 | + 'plain format with tablespaces fails without tablespace mapping'); |
| 80 | + |
| 81 | + command_ok( |
| 82 | + [ 'pg_basebackup', '-D', |
| 83 | + "$tempdir/backup1", '-Fp', |
| 84 | + "-T$shorter_tempdir/tblspc1=$tempdir/tbackup/tblspc1" ], |
| 85 | + 'plain format with tablespaces succeeds with tablespace mapping'); |
| 86 | + ok(-d "$tempdir/tbackup/tblspc1", 'tablespace was relocated'); |
| 87 | + opendir(my $dh, "$tempdir/pgdata/pg_tblspc") or die; |
| 88 | + ok( ( grep |
| 89 | + { |
| 90 | + -l "$tempdir/backup1/pg_tblspc/$_" |
| 91 | + and readlink "$tempdir/backup1/pg_tblspc/$_" eq |
| 92 | + "$tempdir/tbackup/tblspc1" |
| 93 | + } readdir($dh)), |
| 94 | + "tablespace symlink was updated"); |
| 95 | + closedir $dh; |
| 96 | + |
| 97 | + mkdir "$tempdir/tbl=spc2"; |
| 98 | + psql 'postgres', "DROP TABLE test1;"; |
| 99 | + psql 'postgres', "DROP TABLESPACE tblspc1;"; |
| 100 | + psql 'postgres', "CREATE TABLESPACE tblspc2 LOCATION '$shorter_tempdir/tbl=spc2';"; |
| 101 | + command_ok( |
| 102 | + [ 'pg_basebackup', '-D', |
| 103 | + "$tempdir/backup3", '-Fp', |
| 104 | + "-T$shorter_tempdir/tbl\\=spc2=$tempdir/tbackup/tbl\\=spc2" ], |
| 105 | + 'mapping tablespace with = sign in path'); |
| 106 | + ok(-d "$tempdir/tbackup/tbl=spc2", 'tablespace with = sign was relocated'); |
| 107 | + |
| 108 | + psql 'postgres', "DROP TABLESPACE tblspc2;"; |
| 109 | +} |
108 | 110 |
|
109 | 111 | command_fails(
|
110 | 112 | [ 'pg_basebackup', '-D', "$tempdir/backup_foo", '-Fp', "-T=/foo" ],
|
|
0 commit comments