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?)
Addshore created this task.Jun 19 2017, 9:43 AM
Restricted Application added a project: TCB-Team. · View Herald TranscriptJun 19 2017, 9:43 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Addshore claimed this task.Jun 20 2017, 3:14 PM
Addshore added a subscriber: daniel.

An old patch by @daniel @ https://gerrit.wikimedia.org/r/#/c/270555/ could be related here

Addshore moved this task from Backlog to In Progress on the User-Addshore board.Jun 20 2017, 3:15 PM
Addshore moved this task from Proposed to Sprint ready on the WMDE-QWERTY-Team-Board board.

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

Addshore moved this task from Currently in sprint to Done on the WMDE-QWERTY-Team-Board board.

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

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

Addshore closed this task as Resolved.Jun 30 2017, 9:57 AM