]> granicus.if.org Git - postgresql/blob - src/bin/pg_rewind/t/002_databases.pl
Add pg_rewind, for re-synchronizing a master server after failback.
[postgresql] / src / bin / pg_rewind / t / 002_databases.pl
1 use strict;
2 use warnings;
3 use TestLib;
4 use Test::More tests => 2;
5
6 use RewindTest;
7
8 my $testmode = shift;
9
10 RewindTest::init_rewind_test('databases', $testmode);
11 RewindTest::setup_cluster();
12
13 # Create a database in master.
14 master_psql('CREATE DATABASE inmaster');
15
16 RewindTest::create_standby();
17
18 # Create another database, the creation is replicated to the standby
19 master_psql('CREATE DATABASE beforepromotion');
20
21 RewindTest::promote_standby();
22
23 # Create databases in the old master and the new promoted standby.
24 master_psql('CREATE DATABASE master_afterpromotion');
25 standby_psql('CREATE DATABASE standby_afterpromotion');
26 # The clusters are now diverged.
27
28 RewindTest::run_pg_rewind();
29
30 # Check that the correct databases are present after pg_rewind.
31 check_query('SELECT datname FROM pg_database',
32                    qq(template1
33 template0
34 postgres
35 inmaster
36 beforepromotion
37 standby_afterpromotion
38 ),
39                    'database names');
40
41 exit(0);