Skip to content

Commit 5735521

Browse files
committed
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 2cdcae9, 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
1 parent 908a968 commit 5735521

File tree

7 files changed

+39
-12
lines changed

7 files changed

+39
-12
lines changed

src/interfaces/libpq/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ subdir = src/interfaces/libpq
1515
top_builddir = ../../..
1616
include $(top_builddir)/src/Makefile.global
1717

18-
export with_ssl with_gssapi with_krb_srvnam enable_injection_points
18+
export with_ssl with_gssapi with_krb_srvnam
1919

2020
PGFILEDESC = "PostgreSQL Access Library"
2121

src/interfaces/libpq/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ tests += {
121121
't/005_negotiate_encryption.pl',
122122
],
123123
'env': {
124-
'enable_injection_points': get_option('injection_points') ? 'yes' : 'no',
125124
'with_ssl': ssl_library,
126125
'with_gssapi': gssapi.found() ? 'yes' : 'no',
127126
'with_krb_srvnam': 'postgres',

src/interfaces/libpq/t/005_negotiate_encryption.pl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@
9090
$ENV{PG_TEST_EXTRA} && $ENV{PG_TEST_EXTRA} =~ /\bkerberos\b/;
9191
my $ssl_supported = $ENV{with_ssl} eq 'openssl';
9292

93-
my $injection_points_supported = $ENV{enable_injection_points} eq 'yes';
94-
9593
###
9694
### Prepare test server for GSSAPI and SSL authentication, with a few
9795
### different test users and helper functions. We don't actually
@@ -151,6 +149,11 @@
151149

152150
$node->start;
153151

152+
# Check if the extension injection_points is available, as it may be
153+
# possible that this script is run with installcheck, where the module
154+
# would not be installed by default.
155+
my $injection_points_supported = $node->check_extension('injection_points');
156+
154157
$node->safe_psql('postgres', 'CREATE USER localuser;');
155158
$node->safe_psql('postgres', 'CREATE USER testuser;');
156159
$node->safe_psql('postgres', 'CREATE USER ssluser;');

src/test/modules/test_misc/t/005_timeouts.pl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
# Check if the extension injection_points is available, as it may be
2929
# possible that this script is run with installcheck, where the module
3030
# would not be installed by default.
31-
my $result = $node->safe_psql('postgres',
32-
"SELECT count(*) > 0 FROM pg_available_extensions WHERE name = 'injection_points';"
33-
);
34-
if ($result eq 'f')
31+
if (!$node->check_extension('injection_points'))
3532
{
3633
plan skip_all => 'Extension injection_points not installed';
3734
}

src/test/modules/test_misc/t/006_signal_autovacuum.pl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
# This ensures a quick worker spawn.
2626
$node->append_conf('postgresql.conf', 'autovacuum_naptime = 1');
2727
$node->start;
28+
29+
# Check if the extension injection_points is available, as it may be
30+
# possible that this script is run with installcheck, where the module
31+
# would not be installed by default.
32+
if (!$node->check_extension('injection_points'))
33+
{
34+
plan skip_all => 'Extension injection_points not installed';
35+
}
36+
2837
$node->safe_psql('postgres', 'CREATE EXTENSION injection_points;');
2938

3039
$node->safe_psql(

src/test/perl/PostgreSQL/Test/Cluster.pm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2837,6 +2837,28 @@ sub lsn
28372837

28382838
=pod
28392839
2840+
=item $node->check_extension(extension_name)
2841+
2842+
Scan pg_available_extensions to check that an extension is available in an
2843+
installation.
2844+
2845+
Returns 1 if the extension is available, 0 otherwise.
2846+
2847+
=cut
2848+
2849+
sub check_extension
2850+
{
2851+
my ($self, $extension_name) = @_;
2852+
2853+
my $result = $self->safe_psql('postgres',
2854+
"SELECT count(*) > 0 FROM pg_available_extensions WHERE name = '$extension_name';"
2855+
);
2856+
2857+
return $result eq 't' ? 1 : 0;
2858+
}
2859+
2860+
=pod
2861+
28402862
=item $node->wait_for_event(wait_event_name, backend_type)
28412863
28422864
Poll pg_stat_activity until backend_type reaches wait_event_name.

src/test/recovery/t/041_checkpoint_at_promote.pl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838
# Check if the extension injection_points is available, as it may be
3939
# possible that this script is run with installcheck, where the module
4040
# would not be installed by default.
41-
my $result = $node_primary->safe_psql('postgres',
42-
"SELECT count(*) > 0 FROM pg_available_extensions WHERE name = 'injection_points';"
43-
);
44-
if ($result eq 'f')
41+
if (!$node_primary->check_extension('injection_points'))
4542
{
4643
plan skip_all => 'Extension injection_points not installed';
4744
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy