From e8fdb8ec513d870a5f7d78a31a19c0b2204079fe Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 4 Jan 2023 10:09:57 +0100 Subject: [PATCH] Bug 32561: Add test This test does not seem reliable enough, how could we improve it? I guess it will fail randomly, especially if ran in parallel with other processes/tests. Signed-off-by: Kyle M Hall --- xt/memory_check.t | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 xt/memory_check.t diff --git a/xt/memory_check.t b/xt/memory_check.t new file mode 100644 index 0000000000..eaaa860870 --- /dev/null +++ b/xt/memory_check.t @@ -0,0 +1,36 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 1; + +my $pid = qx[ps ax | grep 'background_jobs_worker.pl --queue default' | grep -v grep | tail -n1 | awk '{print \$1}']; + +chomp $pid; + +SKIP: { + skip "No background_jobs_worker.pl process running for the default queue", 1 + unless $pid; + my $memory_usage = qx[pmap -x $pid | tail -n 1 | awk '/[0-9]/{print \$3}']; + chomp $memory_usage; + if ( $memory_usage > 150000 ) { + fail("background_jobs_worker.pl is consuming more than 150Mo in memory: $memory_usage"); + } + else { + pass("background_jobs_worker.pl is consuming $memory_usage in memory"); + } +} -- 2.30.2