Bugzilla – Attachment 31067 Details for
Bug 12800
Can't access MARC bibliographic frameworks and other pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12800: running unit tests that use Koha::Cache breaks cache usage from Apache
Bug-12800-running-unit-tests-that-use-KohaCache-br.patch (text/plain), 3.32 KB, created by
Chris Cormack
on 2014-08-22 00:25:12 UTC
(
hide
)
Description:
Bug 12800: running unit tests that use Koha::Cache breaks cache usage from Apache
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2014-08-22 00:25:12 UTC
Size:
3.32 KB
patch
obsolete
>From 41d4d51fa0117519cb80d2a7dfa6e48767b31cac Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Thu, 21 Aug 2014 15:08:15 -0300 >Subject: [PATCH] Bug 12800: running unit tests that use Koha::Cache breaks > cache usage from Apache > >If the user runs: > > $ prove t/Cache.t > >with it's system user, two situations can happen: > >1) If MEMCACHED_NAMESPACE is set on koha-httpd.xml other than the default 'koha', then > Apache sets /tmp/sharefile-koha-<namespace> and the problem is not present: running > the test creates /tmp/sharefile-koha-koha != /tmp/sharefile-koha-<namespace> >=> SUCCESS: no problem > >2) If MEMCACHED_NAMESPACE is not set (or eq 'koha'), then there is a permission problem >either running the unit tests, or when using any funcitonality on the UI that needs >Koha::Cache. >Explanation: the one that is run first will set the /tmp/sharefile-koha-koha ownership >so it will be either the dev's sys user, or www-data (or whatever apache is using). > >This patch sets a namespace for the unit tests, so there is no collision. > >To test: >- On your dev setup, having MEMCACHED_NAMESPACE unset on koha-httpd.conf >- Edit a marc framework. If it fails, remove /tmp/sharefile-koha-koha, and try again > -> fixed. Now try running > $ prove t/Cache.t >=> FAIL: test fails because of permission problem >- Apply the patch >- Re-run the test >=> SUCCESS: test passes >Try changing the order, etc. > >The temporary file that is used is deleted after the tests are run. > >Sponsored-by: Universidad Nacional de Cordoba >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> >--- > t/Cache.t | 28 ++++++++++++++++++++++++---- > 1 file changed, 24 insertions(+), 4 deletions(-) > >diff --git a/t/Cache.t b/t/Cache.t >index 65cf52b..4c50a2b 100644 >--- a/t/Cache.t >+++ b/t/Cache.t >@@ -1,9 +1,21 @@ > #!/usr/bin/perl > >-# Tests Koha::Cache and whichever type of cache is enabled (through Koha::Cache) >- >-use strict; >-use warnings; >+# 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; > > use Test::More tests => 32; > >@@ -16,6 +28,9 @@ BEGIN { > } > > SKIP: { >+ # Set a special namespace for testing, to avoid breaking >+ # if test is run with a different user than Apache's. >+ $ENV{ MEMCACHED_NAMESPACE } = 'unit_tests'; > my $cache = Koha::Cache->get_instance(); > > skip "Cache not enabled", 28 >@@ -151,9 +166,14 @@ SKIP: { > > END { > SKIP: { >+ $ENV{ MEMCACHED_NAMESPACE } = 'unit_tests'; > my $cache = Koha::Cache->get_instance(); > skip "Cache not enabled", 1 > unless ( $cache->is_cache_active() ); > is( $destructorcount, 1, 'Destructor run exactly once' ); >+ # cleanup temporary file >+ my $tmp_file = $cache->{ fastmmap_cache }->{ share_file }; >+ unlink $tmp_file if defined $tmp_file; >+ > } > } >-- >2.0.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12800
:
31066
|
31067
|
31101