Page MenuHomePhabricator

[EPIC] Multiple Wikibase service wiring tests fail when run as unit tests
Open, Stalled, LowPublic

Description

The service wiring tests we’re adding are supposed to be unit tests that can run without MediaWiki being installed, but some of them fail when run directly via vendor/bin/phpunit (rather than tests/phpunit/phpunit.php).

AC: The following commands, run in the MediaWiki directory, should succeed:

vendor/bin/phpunit extensions/Wikibase/repo/tests/phpunit/unit/ServiceWiring/
vendor/bin/phpunit extensions/Wikibase/client/tests/phpunit/unit/includes/ServiceWiring/

Checklist as of 2021-05-04:

Related Objects

Event Timeline

Change 672744 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] repo: mock LanguageFallbackChainFactory in ValueFormatterFactoryTest

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

Change 672745 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Fix LanguageFallbackChainFactory constructor

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

Change 672746 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] repo: inject TitleFactory into EntitySourceDocumentUrlProvider

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

Change 672747 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] repo: inject LanguageNameUtils into MediaWikiContentLanguages

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

Change 672748 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Inject LanguageNameUtils into MediaWikiContentLanguages

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

Change 672745 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Fix LanguageFallbackChainFactory constructor

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

Change 672746 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] repo: inject TitleFactory into EntitySourceDocumentUrlProvider

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

Change 672744 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] repo: mock LanguageFallbackChainFactory in ValueFormatterFactoryTest

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

Change 672747 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] repo: inject LanguageNameUtils into MediaWikiContentLanguages

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

Change 672748 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Inject LanguageNameUtils into MediaWikiContentLanguages

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

All the tests that are fixable for now have been fixed; I’ve created Phabricator tasks for the MediaWiki services we need in order to fix the rest, and suggest we move this back to our backlog for the time being. If we have some time at the end of our project, we might be able to fix the remaining tests (the MediaWiki core changes should hopefully not be too difficult).

Change 675840 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Make WikiPageEntityMetaDataLookup default to NullLogger

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

Addshore removed a project: Wikidata-Campsite.
Addshore subscribed.

Prioritized very low, so removing from Wikidata-Campsite

I think we should reprioritize this, as it blocks T266441: @kostajh wants to enforce the “unit test-ness” of unit tests, whereas some service wiring tests currently rely on the fact that they can run like integration tests. I really don’t want to turn them into actual integration tests, so we should pursue whatever other changes are necessary so that all of them can actually run as pure unit tests.

ItamarWMDE renamed this task from Multiple Wikibase service wiring tests fail when run as unit tests to [EPIC] Multiple Wikibase service wiring tests fail when run as unit tests.Jan 31 2023, 2:47 PM

Task Triage Notes:

After discussion with PMs and EMs on this topic, we will file this as tech debt to be resolved in a more structured way at a later date.

ItamarWMDE changed the task status from Open to Stalled.Jan 31 2023, 3:27 PM
ItamarWMDE moved this task from Incoming to Epics+STALLED on the Wikidata Dev Team board.

Note that our PHPUnit bootstrap file now assumes unit tests can run without MediaWiki setup, so you’ll get an error if you try to run these tests individually:

$ composer phpunit:entrypoint extensions/Wikibase/repo/tests/phpunit/unit/ServiceWiring/EntityDataUriManagerTest.php
> phpunit 'extensions/Wikibase/repo/tests/phpunit/unit/ServiceWiring/EntityDataUriManagerTest.php'
Using PHP 8.3.1
Running without MediaWiki settings because there are no integration tests
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 00:00.029, Memory: 26.00 MB

There was 1 error:

1) Wikibase\Repo\Tests\Unit\ServiceWiring\EntityDataUriManagerTest::testConstruction
LogicException: Premature access to service container

/srv/http/wiki1/includes/MediaWikiServices.php:325
/srv/http/wiki1/includes/specialpage/SpecialPage.php:169
/srv/http/wiki1/includes/specialpage/SpecialPage.php:155
/srv/http/wiki1/extensions/Wikibase/repo/WikibaseRepo.ServiceWiring.php:760
/srv/http/wiki1/extensions/Wikibase/repo/tests/phpunit/unit/ServiceWiringTestCase.php:90
/srv/http/wiki1/extensions/Wikibase/repo/tests/phpunit/unit/ServiceWiring/EntityDataUriManagerTest.php:41

ERRORS!
Tests: 1, Assertions: 6, Errors: 1.
Script phpunit handling the phpunit event returned with error code 2
Script @phpunit was called via phpunit:entrypoint

I assume they only continue to work in CI because they’re run as part of a bigger test group that still includes integration tests.