Page MenuHomePhabricator

WikibaseClient phpunit tests fail if the "repoDatabase" setting is not false
Closed, ResolvedPublic

Description

If the WikibaseClient setting repoDatabase isn't false, but referring to the local wiki's database by name, the client phpunit tests will fail.

This is because TermSqlIndex (via DBAccessBase which it extends) uses an explicitly passed wiki for calling LoadBalancer::getConnection. The tests use the wiki name from the actual configuration, which makes TermSqlIndex act on the real database and not the cloned one (as the test mocking for MediaWiki doesn't prevent/ handle someone from explicitly wanting a connection to the real DB).

I see a few ways to handle this:

  • Explicitly set the setting to false in all relevant tests
  • Change WikibaseClient::getRepositoryDefinitionsFromSettings so that it ignores the setting in tests
  • Change the MediaWiki LoadBalancer to detect connection attempts to the actual DB and connect to the unittest-clone instead
  • Change DBAccessBase to detect connection attempts to the actual DB and connect to the unittest-clone instead

Event Timeline

Change 504077 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] WikibaseClient tests fail if "repoDatabase" is not false

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

Change 504077 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] WikibaseClient tests fail if "repoDatabase" is not false

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

hoo claimed this task.