From f4a2aef2c725bcf9e6a3be4ca9a5aea2ecbfd912 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. --- 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 00000000000..eaaa860870f --- /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.25.1