Page MenuHomePhabricator

CentralAuth tests broken: The data provider specified for ApiStructureTest::testParameters is invalid
Closed, ResolvedPublic

Description

See for example https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php74-noselenium-docker/113602/console:

There was 1 error:

1) Error
The data provider specified for ApiStructureTest::testParameters is invalid.
Wikimedia\Rdbms\DBQueryError: Error 1044: Access denied for user 'wikiuser'@'localhost' to database 'centralauth'
Function: Wikimedia\Rdbms\DatabaseMysqlBase::doSelectDomain
Query: USE `centralauth`

/workspace/src/includes/libs/rdbms/database/Database.php:1300
/workspace/src/includes/libs/rdbms/database/Database.php:1284
/workspace/src/includes/libs/rdbms/database/Database.php:1258
/workspace/src/includes/libs/rdbms/database/DatabaseMysqlBase.php:201
/workspace/src/includes/libs/rdbms/database/Database.php:1589
/workspace/src/includes/libs/rdbms/loadbalancer/LoadBalancer.php:975
/workspace/src/includes/libs/rdbms/loadbalancer/LoadBalancer.php:848
/workspace/src/includes/libs/rdbms/loadbalancer/LoadBalancer.php:840
/workspace/src/includes/libs/rdbms/database/DBConnRef.php:103
/workspace/src/includes/libs/rdbms/database/DBConnRef.php:117
/workspace/src/includes/libs/rdbms/database/DBConnRef.php:334
/workspace/src/includes/libs/rdbms/querybuilder/SelectQueryBuilder.php:726
/workspace/src/extensions/CentralAuth/includes/GlobalGroup/GlobalGroupLookup.php:57
/workspace/src/extensions/CentralAuth/includes/Api/ApiQueryGlobalAllUsers.php:273
/workspace/src/includes/api/ApiBase.php:1831
/workspace/src/tests/phpunit/structure/ApiStructureTest.php:171
phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97

phpvfscomposer:///workspace/src/vendor/phpunit/phpunit/phpunit:97

Caused by T90875, and in particular CentralAuthHooks::onRegistration no longer finding $wgWikimediaJenkinsCI in the global scope.

But there's also the underlying issue of this code running queries in a dataprovider, which is very problematic (see e.g. T312849, T136348).

Event Timeline

Daimona renamed this task from CentralAuth tests broken: to CentralAuth tests broken: The data provider specified for ApiStructureTest::testParameters is invalid.Jul 12 2023, 8:54 PM

The first thing I'm focusing on is the "queries in dataprovider" issue. The dataprovider in ApiStructureTest calls (amongst other things) ::getAllowedParams() on each module. I'm not aware of restrictions such as "getAllowedParams should not make DB (read) queries". I think there might be benefits in having this restriction. But still, I believe the simplest fix would be to rewrite ApiStructureTest so that it doesn't instantiate anything in the dataProvider. There might be more API modules making queries in the dataprovider that are not caught by existing tests.

Change 937531 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] tests: Avoid DB queries in ApiStructureTest::provideParameters

https://gerrit.wikimedia.org/r/937531

Change 937533 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] phpunit: Special-case $wgWikimediaJenkinsCI in requireOnceInGlobalScope

https://gerrit.wikimedia.org/r/937533

Change 937531 merged by jenkins-bot:

[mediawiki/core@master] tests: Avoid DB queries in ApiStructureTest::provideParameters

https://gerrit.wikimedia.org/r/937531

Change 937533 merged by jenkins-bot:

[mediawiki/core@master] phpunit: Special-case $wgWikimediaJenkinsCI in requireOnceInGlobalScope

https://gerrit.wikimedia.org/r/937533