Bug 12800: running unit tests that use Koha::Cache breaks cache usage from Apache
authorTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 21 Aug 2014 18:08:15 +0000 (15:08 -0300)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Sun, 24 Aug 2014 15:48:34 +0000 (12:48 -0300)
commitd1be7a1506df1ab51a4a0d0d1fb8d500ec11df48
tree0392476103bf16964595f86de3e20456ae968af5
parent07ae4a2fb5f14a12cc8764b4b95fe59d8605d7a1
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>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
t/Cache.t