v1-0001-Allow-creation-of-PostgresNode-subclasses-from-ge.patch
text/x-patch
Filename: v1-0001-Allow-creation-of-PostgresNode-subclasses-from-ge.patch
Type: text/x-patch
Part: 0
Patch
Format: format-patch
Series: patch v1-0001
Subject: Allow creation of PostgresNode subclasses from get_new_node
| File | + | − |
|---|---|---|
| src/test/perl/PostgresNode.pm | 10 | 2 |
From 8a19793c89b165c25c88cd7149650e20ef27bd55 Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig@2ndquadrant.com>
Date: Tue, 30 May 2017 15:18:00 +0800
Subject: [PATCH v1] Allow creation of PostgresNode subclasses from
get_new_node
---
src/test/perl/PostgresNode.pm | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 42e66ed..9f28963 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -853,7 +853,7 @@ sub _update_pid
=pod
-=item get_new_node(node_name)
+=item get_new_node(node_name, node_class)
Build a new PostgresNode object, assigning a free port number. Standalone
function that's automatically imported.
@@ -863,14 +863,20 @@ node, and to ensure that it gets shut down when the test script exits.
You should generally use this instead of PostgresNode::new(...).
+If you have a subclass of PostgresNode you want created, pass its name as the
+second argument. By default a 'PostgresNode' is created.
+
=cut
sub get_new_node
{
my $name = shift;
+ my $pgnclass = shift;
my $found = 0;
my $port = $last_port_assigned;
+ $pgnclass = 'PostgresNode' unless defined $pgnclass;
+
while ($found == 0)
{
@@ -911,7 +917,9 @@ sub get_new_node
print "# Found free port $port\n";
# Lock port number found by creating a new node
- my $node = new PostgresNode($name, $test_pghost, $port);
+ my $node = $pgnclass->new($name, $test_pghost, $port);
+
+ die "$pgnclass must have PostgresNode as a base" if (not ($node->isa("PostgresNode")));
# Add node to list of nodes
push(@all_nodes, $node);
--
2.9.4