aboutsummaryrefslogtreecommitdiff
path: root/src/test/perl/PostgreSQL/Test/Cluster.pm
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-09-05 13:29:43 +0900
committerMichael Paquier <michael@paquier.xyz>2024-09-05 13:29:43 +0900
commit5735521ac2d52485bca673039ba43e2b8cc71cd4 (patch)
tree3371db7b444fb56ba14963d2e4f258790dfe73d2 /src/test/perl/PostgreSQL/Test/Cluster.pm
parent908a968612f9ed61911d8ca0a185b262b82f1269 (diff)
downloadpostgresql-5735521ac2d52485bca673039ba43e2b8cc71cd4.tar.gz
postgresql-5735521ac2d52485bca673039ba43e2b8cc71cd4.zip
Check availability of module injection_points in TAP tests
This fixes defects with installcheck for TAP tests that expect the module injection_points to exist in an installation, but the contents of src/test/modules are not installed by default with installcheck. This would cause, for example, failures under installcheck-world for a build with injection points enabled, when the contents of src/test/modules/ are not installed. The availability of the module can be done with a scan of pg_available_extension. This has been introduced in 2cdcae9da696, and it is refactored here as a new routine in Cluster.pm. Tests are changed in different ways depending on what they need: - The libpq TAP test sets up a node even without injection points, so it is enough to check that CREATE EXTENSION can be used. There is no need for the variable enable_injection_points. - In test_misc, 006_signal_autovacuum requires a runtime check. - 041_checkpoint_at_promote in recovery tests and 005_timeouts in test_misc are updated to use the routine introduced in Cluster.pm. - test_slru's 001_multixact, injection_points's 001_stats and modules/gin/ do not require a check as these modules disable installcheck entirely. Discussion: https://postgr.es/m/ZtesYQ-WupeAK7xK@paquier.xyz
Diffstat (limited to 'src/test/perl/PostgreSQL/Test/Cluster.pm')
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index fe6ebf10f76..143dc8c1015 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -2837,6 +2837,28 @@ sub lsn
=pod
+=item $node->check_extension(extension_name)
+
+Scan pg_available_extensions to check that an extension is available in an
+installation.
+
+Returns 1 if the extension is available, 0 otherwise.
+
+=cut
+
+sub check_extension
+{
+ my ($self, $extension_name) = @_;
+
+ my $result = $self->safe_psql('postgres',
+ "SELECT count(*) > 0 FROM pg_available_extensions WHERE name = '$extension_name';"
+ );
+
+ return $result eq 't' ? 1 : 0;
+}
+
+=pod
+
=item $node->wait_for_event(wait_event_name, backend_type)
Poll pg_stat_activity until backend_type reaches wait_event_name.