Page MenuHomePhabricator

Using setService in setUp results in a new LoadBalancer and new connection meaning temporary tables created for tests no longer exist.
Closed, ResolvedPublic

Description

The below comes from debugging issues with https://gerrit.wikimedia.org/r/#/c/351645/

The issue is that by between the point that the test dbs are setup and the test is run, a new connection is being used and thus the temporary tables that were created are no longer accessible.
This was due to the use of the method setService in the setUp method of the test which calls overrideMwServices if not already calls which replaces the current MediaWikiServices instance, and this new instance has a new LoadBalancer thus we get a new connection.

The rough order of processing is:

  • TestSuite::run
  • MediaWikiTestCase::setUpBeforeClass
  • MediaWikiTestCase::run
  • MediaWikiTestCase::setupAllTestDBs
  • parent::run (phpunit testcase)
  • TestCase::setUp
  • (overrideMwServices called as a result of using setService)
  • TestCase::test
  • (overrideMwServices caused a new services instance, & thus new db connections?)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 362216 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/core@master] Keep the same DBLoadBalancerFactory in tests

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

Change 362216 merged by jenkins-bot:
[mediawiki/core@master] Keep the same DBLoadBalancerFactory in tests

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