|
1 | 1 | # Test for timeline switch
|
2 |
| -# Ensure that a cascading standby is able to follow a newly-promoted standby |
3 |
| -# on a new timeline. |
4 | 2 | use strict;
|
5 | 3 | use warnings;
|
6 | 4 | use File::Path qw(rmtree);
|
7 | 5 | use PostgresNode;
|
8 | 6 | use TestLib;
|
9 |
| -use Test::More tests => 2; |
| 7 | +use Test::More tests => 3; |
10 | 8 |
|
11 | 9 | $ENV{PGDATABASE} = 'postgres';
|
12 | 10 |
|
| 11 | +# Ensure that a cascading standby is able to follow a newly-promoted standby |
| 12 | +# on a new timeline. |
| 13 | + |
13 | 14 | # Initialize primary node
|
14 | 15 | my $node_primary = get_new_node('primary');
|
15 | 16 | $node_primary->init(allows_streaming => 1);
|
|
66 | 67 | my $result =
|
67 | 68 | $node_standby_2->safe_psql('postgres', "SELECT count(*) FROM tab_int");
|
68 | 69 | is($result, qq(2000), 'check content of standby 2');
|
| 70 | + |
| 71 | + |
| 72 | +# Ensure that a standby is able to follow a primary on a newer timeline |
| 73 | +# when WAL archiving is enabled. |
| 74 | + |
| 75 | +# Initialize primary node |
| 76 | +my $node_primary_2 = get_new_node('primary_2'); |
| 77 | +$node_primary_2->init(allows_streaming => 1, has_archiving => 1); |
| 78 | +$node_primary_2->start; |
| 79 | + |
| 80 | +# Take backup |
| 81 | +$node_primary_2->backup($backup_name); |
| 82 | + |
| 83 | +# Create standby node |
| 84 | +my $node_standby_3 = get_new_node('standby_3'); |
| 85 | +$node_standby_3->init_from_backup($node_primary_2, $backup_name, |
| 86 | + has_streaming => 1); |
| 87 | + |
| 88 | +# Restart primary node in standby mode and promote it, switching it |
| 89 | +# to a new timeline. |
| 90 | +$node_primary_2->set_standby_mode; |
| 91 | +$node_primary_2->restart; |
| 92 | +$node_primary_2->promote; |
| 93 | + |
| 94 | +# Start standby node, create some content on primary and check its presence |
| 95 | +# in standby, to ensure that the timeline switch has been done. |
| 96 | +$node_standby_3->start; |
| 97 | +$node_primary_2->safe_psql('postgres', |
| 98 | + "CREATE TABLE tab_int AS SELECT 1 AS a"); |
| 99 | +$node_primary_2->wait_for_catchup($node_standby_3, 'replay', |
| 100 | + $node_primary_2->lsn('write')); |
| 101 | + |
| 102 | +my $result_2 = |
| 103 | + $node_standby_3->safe_psql('postgres', "SELECT count(*) FROM tab_int"); |
| 104 | +is($result_2, qq(1), 'check content of standby 3'); |
0 commit comments