From 3873746ccbfbba7b7e711fde10e60b96caa1605b Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 17 Feb 2016 15:21:32 +0900 Subject: [PATCH 2/3] Add routine for node promotion in PostgresNode This is useful for tests to trigger a promotion on a node via pg_ctl, and pg_rewind can make immediate use of it. --- src/bin/pg_rewind/RewindTest.pm | 2 +- src/test/perl/PostgresNode.pm | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_rewind/RewindTest.pm b/src/bin/pg_rewind/RewindTest.pm index 68834cd..e204830 100644 --- a/src/bin/pg_rewind/RewindTest.pm +++ b/src/bin/pg_rewind/RewindTest.pm @@ -177,7 +177,7 @@ sub promote_standby # Now promote slave and insert some new data on master, this will put # the master out-of-sync with the standby. Wait until the standby is # out of recovery mode, and is ready to accept read-write connections. - system_or_bail('pg_ctl', '-w', '-D', $node_standby->data_dir, 'promote'); + $node_standby->promote; $node_standby->poll_query_until('postgres', "SELECT NOT pg_is_in_recovery()") or die "Timed out while waiting for promotion of standby"; diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index aec3b9a..7efbf5f 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -553,6 +553,25 @@ sub restart $self->_update_pid; } +=pod + +=item $node->promote() + +wrapper for pg_ctl promote + +=cut + +sub promote +{ + my ($self) = @_; + my $port = $self->port; + my $pgdata = $self->data_dir; + my $logfile = $self->logfile; + my $name = $self->name; + print "### Promoting node \"$name\"\n"; + TestLib::system_log('pg_ctl', '-D', $pgdata, '-l', $logfile, + 'promote'); +} # Internal method sub _update_pid -- 2.7.2