Page MenuHomePhabricator

Extension:CloseWikis phpunit tests fail due to missing "closedwikis" database
Closed, ResolvedPublic

Description

22:02:00 Using PHP 5.5.9-1ubuntu4.20
22:02:05 PHPUnit 4.8.31 by Sebastian Bergmann and contributors.
22:02:05 
22:02:06 [dec8388548d4c67e11167c9b] [no req]   DBConnectionError from line 749 of /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/includes/libs/rdbms/database/Database.php: Cannot access the database: Access denied for user 'jenkins_u0'@'127.0.0.1' to database 'closedwikis' (127.0.0.1:3306)
22:02:06 Backtrace:
22:02:06 #0 /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/includes/libs/rdbms/loadbalancer/LoadBalancer.php(932): Database->reportConnectionError(string)

On https://gerrit.wikimedia.org/r/#/c/336041/

Event Timeline

On CI we provision a single database that is named with the prefix jenkins_u + the executor slot on the Jenkins slave (0..2).

closedwikis would comes from Wikimedia dblists, it is not even a database name in production.

Apparently the tests passed on a change sent in October 9th 2016 https://gerrit.wikimedia.org/r/#/c/278535/ . Not sure why it magically starts failing, most probably due to some change in MediaWiki core?

The call chain is roughly:

MediaWikiTestCase->addCoreDBData()
WikiPage->doEditContent(..)
CloseWikis::userCan(..)
CloseWikis::getClosedRow()

When the phpunit.php / MediaWiki test suite prepares the database to run test (probably the MediaWiki core structure ones), it edits some content (maybe populate Main_Page) which trigger UserCan hook which in turns causes close wiki to open a non existent database.

No idea how to solve that one.

Than it sounds like a similar problem as with Premoderation (T157417) where also the initial edits from the phpunit test calling the extension hooks and making the test fail

Krinkle renamed this task from Cannot access the database: Access denied for user 'jenkins_u0'@'127.0.0.1' to database 'closedwikis' to Extension:CloseWikis phpunit tests fail due to missing "closedwikis" database.Mar 20 2018, 9:46 PM
hashar claimed this task.

Eventually I fixed it with d66235cf338e474921e8148851e7a1970512e143 . I have added a hack for CI which causes the extension to use the current database as the shared one.