From d55354bffef31db7da42d02ebb859fb8ae2903c3 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Wed, 4 Jan 2023 06:52:03 -0500 Subject: [PATCH] Bug 32561: Test loaded modules for background_jobs_worker.pl Signed-off-by: Kyle M Hall --- misc/background_jobs_worker.pl | 8 ++++++-- xt/memory_check.t | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl index eb36f34f96..213b4ad711 100755 --- a/misc/background_jobs_worker.pl +++ b/misc/background_jobs_worker.pl @@ -21,7 +21,7 @@ background_jobs_worker.pl - Worker script that will process background jobs =head1 SYNOPSIS -./background_jobs_worker.pl [--queue QUEUE] +./background_jobs_worker.pl [--queue QUEUE] [-m] =head1 DESCRIPTION @@ -30,6 +30,7 @@ or if a Stomp server is not active it will poll the database every 10s for new j You can specify some queues only (using --queue, which is repeatable) if you want to run several workers that will handle their own jobs. +-m or --modules will cause the script to print the included Perl modules and exit. =head1 OPTIONS =over @@ -55,14 +56,17 @@ use Getopt::Long; use Koha::BackgroundJobs; -my ( $help, @queues ); +my ( $help, @queues, $modules ); GetOptions( 'h|help' => \$help, 'queue=s' => \@queues, + 'm|modules' => \$modules, ) || pod2usage(1); pod2usage(0) if $help; +if ($modules) { print join "\n", %INC; print "\n"; exit 0; } + unless (@queues) { push @queues, 'default'; } diff --git a/xt/memory_check.t b/xt/memory_check.t index eaaa860870..833509fd1a 100644 --- a/xt/memory_check.t +++ b/xt/memory_check.t @@ -16,7 +16,8 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 1; +use Test::More tests => 2; +use FindBin; my $pid = qx[ps ax | grep 'background_jobs_worker.pl --queue default' | grep -v grep | tail -n1 | awk '{print \$1}']; @@ -34,3 +35,6 @@ SKIP: { pass("background_jobs_worker.pl is consuming $memory_usage in memory"); } } + +my $output = qx{$FindBin::Bin/../misc/background_jobs_worker.pl -m | grep 'Koha/Plugins.pm'}; +is( $output, q{}, "Koha::Plugins not loaded by background_jobs_worker.pl" ); -- 2.30.2