Page MenuHomePhabricator

CentralAuth causes DBAccessError in non-database phpunit suite
Closed, ResolvedPublic

Description

During the non-database phpunit suite (for example in: https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-hhvm-docker/9892/console)

This database teardown step tries to run but fails.

Warning: Destructor threw an object exception: exception 'Wikimedia\Rdbms\DBAccessError' with message 'Database access has been disabled.' in /workspace/src/includes/libs/rdbms/loadbalancer/LoadBalancer.php:1064
08:40:37 Stack trace:
08:40:37 #0 /workspace/src/includes/libs/rdbms/loadbalancer/LoadBalancer.php(904): Wikimedia\Rdbms\LoadBalancer->reallyOpenConnection()
08:40:37 #1 /workspace/src/includes/libs/rdbms/loadbalancer/LoadBalancer.php(765): Wikimedia\Rdbms\LoadBalancer->openConnection()
08:40:37 #2 /workspace/src/includes/GlobalFunctions.php(2798): Wikimedia\Rdbms\LoadBalancer->getConnection()
08:40:37 #3 /workspace/src/extensions/CentralAuth/includes/CentralAuthHooks.php(1528): wfGetDB()
08:40:37 #4 /workspace/src/includes/Hooks.php(174): CentralAuthHooks::onUnitTestsBeforeDatabaseTeardown()
08:40:37 #5 /workspace/src/includes/Hooks.php(202): Hooks::callHook()
08:40:37 #6 /workspace/src/tests/phpunit/MediaWikiTestCase.php(1279): Hooks::run()
08:40:37 #7 /workspace/src/tests/phpunit/bootstrap.php(20): MediaWikiTestCase::teardownTestDB()
08:40:37 #8 (): MediaWikiPHPUnitBootstrap->__destruct()
08:40:37 #9 {main}

Event Timeline

Tarrow renamed this task from CentralAuth tries to access database during the non-database unittests to CentralAuth causes DBAccessError in non-database phpunit suite.Aug 6 2018, 8:49 AM

This exception from CentralAuth code sometimes causes Jenkins jobs for MediaWiki core commits to fail (via the shared integration job). It also affects commits in the repositories for other extensions that are themselves in the shared stable gate, which includes CentralAuth itself and ContentTranslation.

Example at https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/ContentTranslation/+/449441/, https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-hhvm-docker/9892/console.

Unable to tag a team, as mw:Maintainers still lists "CentralAuth" as Unassigned.

Krinkle triaged this task as High priority.Aug 29 2018, 2:07 AM
Krinkle removed a project: MediaWiki-Core-Tests.
Tgr subscribed.

This is a core problem IMO. Don't call the UnitTestsBeforeDatabaseTeardown hook if there is no database to tear down.

But then MediaWikiTestCase::teardownTestDB() has a check for exactly that. And it seems impossible to bypass that checks unless MediaWikiTestCase::setupTestDB() was invoked earlier. Which is invoked on every test, DB or not :(

So maybe T155147: Do not initialise the database in tests when not needed would be the place to start.

Krinkle changed the task status from Open to Stalled.Dec 8 2018, 10:01 PM
Krinkle removed a project: MediaWiki-Core-Tests.

Okay, so it sounds like this bug would automatically fix itself when the core behaviour is changed as part of T155147.

On that assumption, marking as subtask and stalled until then. Untagging core-tests as this task does not seem to itself describe a task that results in changing core's test infra (given T155147). If incorrect, please undo :)

Daimona claimed this task.

Per above, resolving because T155147 has been resolved, and no DB setup/teardown occurs in the databaseless suite.