Page MenuHomePhabricator

filebackend tests should use their own $wgFilebackends configuration
Open, MediumPublic

Description

Example:

  1. FileBackendTest::testStore with data set #2 (array('store', '/tmp/unittests_57b55ccf5688-1.txt', 'mwstore://localtesting/unittest-cont1/e/fun/obj1.txt', true), '/tmp/unittests_57b55ccf5688-1.txt', 'mwstore://localtesting/unittest-cont1/e/fun/obj1.txt')

fopen(/www/w/images/lockdir/khsf3ntb7why6dhpaq76lvaw45uil3u.lock): failed to open stream: Permission denied

/www/dev.translatewiki.net/w/includes/filebackend/lockmanager/FSLockManager.php:123
/www/dev.translatewiki.net/w/includes/filebackend/lockmanager/FSLockManager.php:74
/www/dev.translatewiki.net/w/includes/filebackend/lockmanager/LockManager.php:77
/www/dev.translatewiki.net/w/includes/filebackend/lockmanager/LockManager.php:173
/www/dev.translatewiki.net/w/includes/filebackend/FileBackend.php:966
/www/dev.translatewiki.net/w/includes/filebackend/FileBackendStore.php:516
/www/dev.translatewiki.net/w/includes/filebackend/FileBackend.php:682
/www/dev.translatewiki.net/w/tests/phpunit/includes/filerepo/FileBackendTest.php:1851
/www/dev.translatewiki.net/w/tests/phpunit/includes/filerepo/FileBackendTest.php:1837
/www/dev.translatewiki.net/w/tests/phpunit/includes/filerepo/FileBackendTest.php:202
/www/dev.translatewiki.net/w/tests/phpunit/MediaWikiTestCase.php:84
/www/dev.translatewiki.net/w/tests/phpunit/MediaWikiPHPUnitCommand.php:45
/www/dev.translatewiki.net/w/tests/phpunit/phpunit.php:107

I think it should use temporary folder for these tests.


Version: 1.19.1
Severity: normal

Details

Reference
bz40491

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:09 AM
bzimport set Reference to bz40491.
bzimport added a subscriber: Unknown Object (MLST).

What are the perms for the lockdir?

drwxr-sr-x 2 www-data betawiki 4,0K 2012-09-16 19:31 ./

I guess /www/w/images/lockdir/ should be fixed to be group writable or you will get the same issue with any maintenance script using the filebackend unless they are being run under the www-data user account.

About the test suite itself, we should probably override the $wgFilebackend stuff with a custom configuration using /tmp as root. We could also attempt to mock the filesystem as described on http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mocking-the-filesystem but that will add yet another layer.

Rephrased subject.

Failing tests are not an enhancement imho.

Does using wgFilebackend fix the failure Niklas showed in comment 0?

Looks like a permissions issue. Is it a valid requirement that the "lockdir/" in uploaddir is writeable? If so, then this bug is invalid (or an enhancement to show the error earlier). If it shouldn't use "/lockdir" there but elsewhere, then what should it use, and does that make it work?

(In reply to comment #4)

Failing tests are not an enhancement imho.

They are failing because of a well known permission issue: your cli script and apache process have different user and are probably not in the same group and not having umask 0002. So yeah that is mostly a local issue, the enhancement would be to make the test work on such setup.

The tests should just override the lockdir location to a temporary location. MediaWiki shouldn't assume that writable upload directory is configured by default.

Looks like lockdir comes from Setup.php:

132-$wgLockManagers[] = array(
133- 'name' => 'fsLockManager',
134- 'class' => 'FSLockManager',
135: 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
136-);

I ran core tests yesterday and didn't see failures related to this.