|
1 | 1 | use strict;
|
2 | 2 | use warnings;
|
3 | 3 | use TestLib;
|
4 |
| -use Test::More tests => 11; |
| 4 | +use Test::More tests => 15; |
5 | 5 |
|
6 | 6 | use FindBin;
|
7 | 7 | use lib $FindBin::RealBin;
|
@@ -66,6 +66,71 @@ sub run_test
|
66 | 66 | master_psql("DELETE FROM tail_tbl WHERE id > 10");
|
67 | 67 | master_psql("VACUUM tail_tbl");
|
68 | 68 |
|
| 69 | + # Before running pg_rewind, do a couple of extra tests with several |
| 70 | + # option combinations. As the code paths taken by those tests |
| 71 | + # do not change for the "local" and "remote" modes, just run them |
| 72 | + # in "local" mode for simplicity's sake. |
| 73 | + if ($test_mode eq 'local') |
| 74 | + { |
| 75 | + my $master_pgdata = $node_master->data_dir; |
| 76 | + my $standby_pgdata = $node_standby->data_dir; |
| 77 | + |
| 78 | + # First check that pg_rewind fails if the target cluster is |
| 79 | + # not stopped as it fails to start up for the forced recovery |
| 80 | + # step. |
| 81 | + command_fails( |
| 82 | + [ |
| 83 | + 'pg_rewind', '--debug', |
| 84 | + '--source-pgdata', $standby_pgdata, |
| 85 | + '--target-pgdata', $master_pgdata, |
| 86 | + '--no-sync' |
| 87 | + ], |
| 88 | + 'pg_rewind with running target'); |
| 89 | + |
| 90 | + # Again with --no-ensure-shutdown, which should equally fail. |
| 91 | + # This time pg_rewind complains without attempting to perform |
| 92 | + # recovery once. |
| 93 | + command_fails( |
| 94 | + [ |
| 95 | + 'pg_rewind', '--debug', |
| 96 | + '--source-pgdata', $standby_pgdata, |
| 97 | + '--target-pgdata', $master_pgdata, |
| 98 | + '--no-sync', '--no-ensure-shutdown' |
| 99 | + ], |
| 100 | + 'pg_rewind --no-ensure-shutdown with running target'); |
| 101 | + |
| 102 | + # Stop the target, and attempt to run with a local source |
| 103 | + # still running. This fails as pg_rewind requires to have |
| 104 | + # a source cleanly stopped. |
| 105 | + $node_master->stop; |
| 106 | + command_fails( |
| 107 | + [ |
| 108 | + 'pg_rewind', '--debug', |
| 109 | + '--source-pgdata', $standby_pgdata, |
| 110 | + '--target-pgdata', $master_pgdata, |
| 111 | + '--no-sync', '--no-ensure-shutdown' |
| 112 | + ], |
| 113 | + 'pg_rewind with unexpected running source'); |
| 114 | + |
| 115 | + # Stop the target cluster cleanly, and run again pg_rewind |
| 116 | + # with --dry-run mode. If anything gets generated in the data |
| 117 | + # folder, the follow-up run of pg_rewind will most likely fail, |
| 118 | + # so keep this test as the last one of this subset. |
| 119 | + $node_standby->stop; |
| 120 | + command_ok( |
| 121 | + [ |
| 122 | + 'pg_rewind', '--debug', |
| 123 | + '--source-pgdata', $standby_pgdata, |
| 124 | + '--target-pgdata', $master_pgdata, |
| 125 | + '--no-sync', '--dry-run' |
| 126 | + ], |
| 127 | + 'pg_rewind --dry-run'); |
| 128 | + |
| 129 | + # Both clusters need to be alive moving forward. |
| 130 | + $node_standby->start; |
| 131 | + $node_master->start; |
| 132 | + } |
| 133 | + |
69 | 134 | RewindTest::run_pg_rewind($test_mode);
|
70 | 135 |
|
71 | 136 | check_query(
|
|
0 commit comments