Extend compatibility of PostgreSQL::Test::Cluster

Started by Andrew Dunstanover 4 years ago10 messageshackers
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

PFA a patch to extend the compatibility of PostgreSQL::Test::Cluster to
all live branches. It does this by introducing a couple of subclasses
which override a few things. The required class is automatically
detected and used, so users don't need to specify a subclass. Although
this is my work it draws some inspiration from work by Jehan-Guillaume
de Rorthais. The aim here is to provide minimal disruption to the
mainline code, and also to have very small override subroutines.

My hope is to take this further, down to 9.2, which we recently decided
to give limited build support to. However I think the present patch is a
good stake to put into the ground.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Attachments:

cluster-compat-extension.patchtext/x-patch; charset=UTF-8; name=cluster-compat-extension.patchDownload+65-9
#2Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#1)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On 12/28/21 09:30, Andrew Dunstan wrote:

PFA a patch to extend the compatibility of PostgreSQL::Test::Cluster to
all live branches. It does this by introducing a couple of subclasses
which override a few things. The required class is automatically
detected and used, so users don't need to specify a subclass. Although
this is my work it draws some inspiration from work by Jehan-Guillaume
de Rorthais. The aim here is to provide minimal disruption to the
mainline code, and also to have very small override subroutines.

My hope is to take this further, down to 9.2, which we recently decided
to give limited build support to. However I think the present patch is a
good stake to put into the ground.

This version handles older versions for which we have no subclass more
gracefully.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Attachments:

cluster-compat-extension-v2.patchtext/x-patch; charset=UTF-8; name=cluster-compat-extension-v2.patchDownload+69-9
In reply to: Andrew Dunstan (#2)
Re: Extend compatibility of PostgreSQL::Test::Cluster

Andrew Dunstan <andrew@dunslane.net> writes:

+		my $subclass = __PACKAGE__ . "::V_$maj";
+		bless $node, $subclass;
+		unless ($node->isa(__PACKAGE__))
+		{
+			# It's not a subclass, so re-bless back into the main package
+			bless($node, __PACKAGE__);
+			carp "PostgreSQL::Test::Cluster isn't fully compatible with version $ver";
+		}

The ->isa() method works on package names as well as blessed objects, so
the back-and-forth blessing can be avoided.

my $subclass = __PACKAGE__ . "::V_$maj";
if ($subclass->isa(__PACKAGE__))
{
bless($node, $subclass);
}
else
{
carp "PostgreSQL::Test::Cluster isn't fully compatible with version $ver";
}

- ilmari

#4Andrew Dunstan
andrew@dunslane.net
In reply to: Dagfinn Ilmari Mannsåker (#3)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On 12/31/21 11:20, Dagfinn Ilmari Mannsåker wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

+		my $subclass = __PACKAGE__ . "::V_$maj";
+		bless $node, $subclass;
+		unless ($node->isa(__PACKAGE__))
+		{
+			# It's not a subclass, so re-bless back into the main package
+			bless($node, __PACKAGE__);
+			carp "PostgreSQL::Test::Cluster isn't fully compatible with version $ver";
+		}

The ->isa() method works on package names as well as blessed objects, so
the back-and-forth blessing can be avoided.

my $subclass = __PACKAGE__ . "::V_$maj";
if ($subclass->isa(__PACKAGE__))
{
bless($node, $subclass);
}
else
{
carp "PostgreSQL::Test::Cluster isn't fully compatible with version $ver";
}

OK, thanks, will fix in next version.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#4)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On 12/31/21 11:22, Andrew Dunstan wrote:

On 12/31/21 11:20, Dagfinn Ilmari Mannsåker wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

+		my $subclass = __PACKAGE__ . "::V_$maj";
+		bless $node, $subclass;
+		unless ($node->isa(__PACKAGE__))
+		{
+			# It's not a subclass, so re-bless back into the main package
+			bless($node, __PACKAGE__);
+			carp "PostgreSQL::Test::Cluster isn't fully compatible with version $ver";
+		}

The ->isa() method works on package names as well as blessed objects, so
the back-and-forth blessing can be avoided.

my $subclass = __PACKAGE__ . "::V_$maj";
if ($subclass->isa(__PACKAGE__))
{
bless($node, $subclass);
}
else
{
carp "PostgreSQL::Test::Cluster isn't fully compatible with version $ver";
}

OK, thanks, will fix in next version.

Here's a version that does that and removes some recent bitrot.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Attachments:

cluster-compat-extension-v3.patchtext/x-patch; charset=UTF-8; name=cluster-compat-extension-v3.patchDownload+70-9
#6Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#5)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On Tue, Jan 18, 2022 at 06:35:39PM -0500, Andrew Dunstan wrote:

Here's a version that does that and removes some recent bitrot.

I have been looking at the full set of features of Cluster.pm and the
requirements behind v10 as minimal version supported, and nothing
really stands out.

+   # old versions of walreceiver just set the application name to
+   # `walreceiver'

Perhaps this should mention to which older versions this sentence
applies?
--
Michael

#7Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#6)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On 1/21/22 02:47, Michael Paquier wrote:

On Tue, Jan 18, 2022 at 06:35:39PM -0500, Andrew Dunstan wrote:

Here's a version that does that and removes some recent bitrot.

I have been looking at the full set of features of Cluster.pm and the
requirements behind v10 as minimal version supported, and nothing
really stands out.

+   # old versions of walreceiver just set the application name to
+   # `walreceiver'

Perhaps this should mention to which older versions this sentence
applies?

Will do in the next version. FTR it's versions older than 12.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#8Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#7)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On 1/21/22 09:59, Andrew Dunstan wrote:

On 1/21/22 02:47, Michael Paquier wrote:

On Tue, Jan 18, 2022 at 06:35:39PM -0500, Andrew Dunstan wrote:

Here's a version that does that and removes some recent bitrot.

I have been looking at the full set of features of Cluster.pm and the
requirements behind v10 as minimal version supported, and nothing
really stands out.

+   # old versions of walreceiver just set the application name to
+   # `walreceiver'

Perhaps this should mention to which older versions this sentence
applies?

Will do in the next version. FTR it's versions older than 12.

I'm not sure why this item has been moved to the next CF without any
discussion I could see on the mailing list. It was always my intention
to commit it this time, and I propose to do so tomorrow with the comment
Michael has requested above. The cfbot is still happy with it.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#9Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#8)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On Tue, Mar 29, 2022 at 05:56:02PM -0400, Andrew Dunstan wrote:

I'm not sure why this item has been moved to the next CF without any
discussion I could see on the mailing list. It was always my intention
to commit it this time, and I propose to do so tomorrow with the comment
Michael has requested above. The cfbot is still happy with it.

Thanks for taking care of it!
--
Michael

#10Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#9)
Re: Extend compatibility of PostgreSQL::Test::Cluster

On 3/30/22 01:55, Michael Paquier wrote:

On Tue, Mar 29, 2022 at 05:56:02PM -0400, Andrew Dunstan wrote:

I'm not sure why this item has been moved to the next CF without any
discussion I could see on the mailing list. It was always my intention
to commit it this time, and I propose to do so tomorrow with the comment
Michael has requested above. The cfbot is still happy with it.

Thanks for taking care of it!

Committed.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com