Page MenuHomePhabricator

Make PHPUnit tests pass on Travis CI
Closed, ResolvedPublic

Description

The current status of the tests can be viewed at https://travis-ci.org/wikimedia/mediawiki.

Details

Reference
bz73176

Related Objects

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:59 AM
bzimport set Reference to bz73176.
bzimport added a subscriber: Unknown Object (MLST).
scfc created this task.Nov 8 2014, 2:30 PM
scfc triaged this task as Normal priority.Nov 28 2014, 9:15 PM
scfc set Security to None.
Krinkle added a subscriber: Krinkle.Jan 5 2015, 1:38 AM

1 failing test left:

............................................................. 9577 / 9606 ( 99%)
.............................

Time: 11.87 minutes, Memory: 768.75Mb

There was 1 failure:

1) TextPassDumperTest::testCheckpointPlain
expected more than 1 checkpoint to have been created. Checkpoint interval is 0.5 seconds, maybe your computer is too fast?
Failed asserting that 1 is greater than 1.
/home/travis/build/wikimedia/mediawiki/tests/phpunit/maintenance/backupTextPassTest.php:412
/home/travis/build/wikimedia/mediawiki/tests/phpunit/maintenance/backupTextPassTest.php:421
/home/travis/build/wikimedia/mediawiki/tests/phpunit/MediaWikiTestCase.php:141
Krinkle renamed this task from Make Travis CI pass all tests to Make PHPUnit tests pass on Travis CI.Jan 5 2015, 1:38 AM
Krinkle updated the task description. (Show Details)
Krinkle removed a subscriber: Unknown Object (MLST).
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 11 2016, 11:30 PM
Krinkle added a comment.EditedJul 29 2016, 8:22 PM

Still one failure left (different one):

https://travis-ci.org/wikimedia/mediawiki/jobs/148367593

There was 1 failure:
1) LBFactoryTest::testLBFactorySimpleServers
cluster master set
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-''
+'localhost'
/home/travis/build/wikimedia/mediawiki/tests/phpunit/includes/db/LBFactoryTest.php:107
/home/travis/build/wikimedia/mediawiki/tests/phpunit/MediaWikiTestCase.php:390

mediawiki:/tests/phpunit/includes/db/LBFactoryTest.php#L104-L107

		$dbw = $lb->getConnection( DB_MASTER );
		$this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
		$this->assertEquals(
			$wgDBserver, $dbw->getLBInfo( 'clusterMasterHost' ), 'cluster master set' );
Krinkle removed a subscriber: Krinkle.Aug 14 2016, 5:40 AM

Change 339112 had a related patch set uploaded (by Krinkle):
resourceloader: Fix testMakeModuleResponseError() failure on Travis

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

Change 339112 merged by jenkins-bot:
resourceloader: Fix testMakeModuleResponseError() failure on Travis

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

The following happens in at least the PHP 5.5 and PHP 7 builds on Travis (the HHVM build is currently failing earlier with something else, so can't see that one right now).

https://travis-ci.org/wikimedia/mediawiki/jobs/204056486

1) UploadBaseTest::testDetectScriptInSvg with data set #3 ('/home/travis/build/wikimedia/...ad.svg', array('uploadscriptednamespace', 'i'), 'SVG with a namespace definiti...entity')
SVG with a namespace definition using an undefined entity
Failed asserting that Array &0 (
    0 => 'uploadinvalidxml'
) is identical to Array &0 (
    0 => 'uploadscriptednamespace'
    1 => 'i'
).

Change 339346 had a related patch set uploaded (by Krinkle):
phpunit: Fix AvroFormatterTest failure on PHP 7

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

Change 339346 merged by jenkins-bot:
phpunit: Fix AvroFormatterTest failure on PHP 7

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

Change 339592 had a related patch set uploaded (by Krinkle):
build: Change Travis postgres user "root" back to "travis"

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

Change 339593 had a related patch set uploaded (by Krinkle):
build: Simplify Travis configuration

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

Change 339594 had a related patch set uploaded (by Krinkle):
installer: Fix "relation 'user' does not exist" error for Postgres

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

Krinkle added a comment.EditedFeb 24 2017, 3:43 AM

Yesterday, all 4 builds (PHP 5.5 mysql, postgres; HHVM; PHP 7) were failing.

  • PHP 5.5 (mysql, postgres) / PHP 7: UploadBaseTest::testDetectScriptInSvg failure.
  • HHVM: PHPSessionHandlerTest failing.

closed subtask T75175: Make PHPUnit tests pass with hhvm/MySQL on Travis CI as "Resolved".

Travis CI HHVM build is passing now. Fixed by 5168cb60f8ff3f. Main problem was that we needed to update from HHVM 3.6 to HHVM 3.12.

This upgrade also required switching the Travis CI build from using Ubuntu Precise to Ubuntu Trusty.

On the plus side, the Ubuntu upgrade also fixed the UploadBaseTest failures. Presumably the native xml library that Zend PHP binds to in Precise was more struct (used by UploadBase/XmlTypeCheck).

The PHP 5.5 build is passing now.

Change 339346 merged by jenkins-bot:
phpunit: Fix AvroFormatterTest failure on PHP 7
https://gerrit.wikimedia.org/r/339346

The PHP 7 build is passing now.

Postgres is still failing before the installer ends (before PHPUnit even starts). The main error in recent months was:

wikimedia/mediawiki - dbtype:postgres - php:5.5
Creating administrator user account.. DBQueryError from line 1059 of includes/libs/rdbms/database/Database.php:
 Query: SELECT  user_id  FROM "user"    WHERE user_name = 'Admin'  LIMIT 1  
 Function: User::idForName
 Error: 42P01 ERROR:  relation "user" does not exist
 LINE 1: SELECT /* User::idForName  */  user_id  FROM "user"    WHERE...

This is because the keywordTableMap configuration that maps user to mwuser for DatabasePostgres is somehow not being applied to the Database instance that the User class gets when it calls wfGetDB(). Normally this is set via MWLBFactory by ServiceWiring.

The installer has its own connection that is created directly via Database::factory without MWLBFactory or MediaWikiServices, and therefore without keywordTableMap. That part is fine in itself since there's no need for a keyword map when merely creating the database and tables. Later on, when User::idForName calls wfGetDB(), it is somehow getting that same keyword-map-less connection from MediaWikiServices!

The first call happens in Setup.php, MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( .. ). Which wrongly creates an LBFactory for mysql (default) instead of postgres because the installer hasn't yet loaded the configuration.

wikimedia/mediawiki - dbtype:postgres - php:5.5
$ php maintenance/install.php traviswiki admin --pass travis --dbtype "$dbtype" --dbname traviswiki --dbuser "$dbuser" --dbpass "" --scriptpath "/w"

ServiceWiring.php line 47 calls wfBacktrace()
ServiceContainer.php line 361 calls call_user_func_array()
ServiceContainer.php line 344 calls MediaWiki\Services\ServiceContainer->createService()
MediaWikiServices.php line 501 calls MediaWiki\Services\ServiceContainer->getService()
Setup.php line 664 calls MediaWiki\MediaWikiServices->getDBLoadBalancerFactory()
doMaintenance.php line 98 calls require_once()
install.php line 156 calls require_once()

# ServiceWiring.php#closure_DBLoadBalancerFactory / LBFactoryConf is:
array(1) {
  'class' =>
  string(15) "LBFactorySimple"
}
# MWLBFactory::applyDefaultConfig else / server is:
array(10) {
  'host' =>
  string(9) "localhost"
  'user' =>
  string(8) "wikiuser"
  'password' =>
  string(0) ""
  'dbname' =>
  string(7) "my_wiki"
  'tablePrefix' =>
  string(0) ""
  'type' =>
  string(5) "mysql"
  'load' =>
  int(1)
  'flags' =>
  int(16)
  'sqlMode' =>
  string(0) ""
  'utf8Mode' =>
  bool(false)
}

The ServiceWiring for DBLoadBalancerFactory never gets called a second time, despite the Installer constructor resetting the global MediaWikiServices instance. So MWLBFactory never gets applied with postgres during the installer.

Turns out, after the Installer constructor is done, but before any "real" code, DatabaseInstaller::enableLB takes the installer's homemade connection (for db table creation) and injects it into MediaWikiServices by redefining 'DBLoadBalancerFactory'.

Fixed in https://gerrit.wikimedia.org/r/#/c/339594/1. Postgres remains failing with about 4 PHPUnit failures. See T75174.

Change 339592 merged by jenkins-bot:
build: Change Travis postgres user "root" back to "travis"

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

Change 339593 merged by jenkins-bot:
build: Simplify Travis configuration

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

Change 339594 merged by jenkins-bot:
installer: Fix "relation 'user' does not exist" error for Postgres

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

Change 345079 had a related patch set uploaded (by Krinkle):
[mediawiki/core@master] build: Make Travis CI 'Postgres' build non-voting

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

Change 345079 merged by jenkins-bot:
[mediawiki/core@master] build: Make Travis CI 'Postgres' build non-voting

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

Change 345249 had a related patch set uploaded (by Krinkle):
[mediawiki/core@REL1_28] build: Make Travis CI 'Postgres' build non-voting

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

Change 345249 merged by jenkins-bot:
[mediawiki/core@REL1_28] build: Make Travis CI 'Postgres' build non-voting

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

Krinkle moved this task from Inbox to PHPUnit on the MediaWiki-Core-Testing board.Jul 7 2017, 5:14 AM
Krinkle closed this task as Resolved.Jul 29 2017, 1:48 AM
Krinkle claimed this task.

Change 424509 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/core@REL1_27] phpunit: Fix AvroFormatterTest failure on PHP 7

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

Change 424509 merged by jenkins-bot:
[mediawiki/core@REL1_27] phpunit: Fix AvroFormatterTest failure on PHP 7

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