Addition of PostgreSQL::Test::Cluster::pg_version()

Started by Michael Paquierover 3 years ago5 messages
#1Michael Paquier
michael@paquier.xyz
1 attachment(s)

Hi all,
(Added Andrew in CC.)

While working more on expanding the tests of pg_upgrade for
cross-version checks, I have noticed that we don't expose a routine
able to get back _pg_version from a node, which should remain a
private field of Cluster.pm. We already do that for install_path, as
of case added by 87076c4.

Any objections or comments about the addition of a routine to get the
PostgreSQL::Version, as of the attached?

Thanks,
--
Michael

Attachments:

tap-pg-version.patchtext/x-diff; charset=us-asciiDownload
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index f842be1a72..c8c7bc5045 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -331,6 +331,20 @@ sub install_path
 
 =pod
 
+=item $node->pg_version()
+
+The version number for the node, from PostgreSQL::Version.
+
+=cut
+
+sub pg_version
+{
+	my ($self) = @_;
+	return $self->{_pg_version};
+}
+
+=pod
+
 =item $node->config_data($option)
 
 Return a string holding configuration data from pg_config, with $option
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Michael Paquier (#1)
Re: Addition of PostgreSQL::Test::Cluster::pg_version()

On 19 May 2022, at 03:38, Michael Paquier <michael@paquier.xyz> wrote:

Any objections or comments about the addition of a routine to get the
PostgreSQL::Version, as of the attached?

I haven't tested the patch, but +1 on the idea.

--
Daniel Gustafsson https://vmware.com/

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Michael Paquier (#1)
Re: Addition of PostgreSQL::Test::Cluster::pg_version()

On 2022-05-18 We 21:38, Michael Paquier wrote:

Hi all,
(Added Andrew in CC.)

While working more on expanding the tests of pg_upgrade for
cross-version checks, I have noticed that we don't expose a routine
able to get back _pg_version from a node, which should remain a
private field of Cluster.pm. We already do that for install_path, as
of case added by 87076c4.

Any objections or comments about the addition of a routine to get the
PostgreSQL::Version, as of the attached?

Looks ok. PostgreSQL::Version is designed so that the object behaves
sanely in comparisons and when interpolated into a string.

cheers

andrew

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

#4Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#3)
Re: Addition of PostgreSQL::Test::Cluster::pg_version()

On Thu, May 19, 2022 at 07:28:53AM -0400, Andrew Dunstan wrote:

Looks ok. PostgreSQL::Version is designed so that the object behaves
sanely in comparisons and when interpolated into a string.

I saw that, and that's kind of nice when it comes to write
version-specific code paths in the tests ;)
--
Michael

#5Michael Paquier
michael@paquier.xyz
In reply to: Andrew Dunstan (#3)
Re: Addition of PostgreSQL::Test::Cluster::pg_version()

On Thu, May 19, 2022 at 07:28:53AM -0400, Andrew Dunstan wrote:

Looks ok. PostgreSQL::Version is designed so that the object behaves
sanely in comparisons and when interpolated into a string.

Okay, I have applied this thing. I'll move back to my business with
the tests of pg_upgrade...
--
Michael