Page MenuHomePhabricator

MediaWikiTestCase::copyTestData does not work on Postgres and SQLite
Closed, ResolvedPublic

Description

When trying to merge If4c31b7975b4d90 for T198706, it was discovered that MediaWikiTestCase::copyTestData does not work on Postgres and SQLite.

Anomie's analysis indicates two separate causes (comment copied from gerrit):

For postgres, MediaWikiTestCase::listOriginalTables() is broken and only happens to work on MySQL because the undocumented listTables() method doesn't return temporary tables on that DB (while it does on postgres).
For sqlite, you're running into the problem described at T191863#4130112. TL;DR: if you do open the same database twice and do schema changes on one connection, the other will notice that and reset itself, losing the temporary tables. Probably all the creations of temporary tables for sqlite are ok, but unittest_searchindex can't be temporary so that's probably the one screwing it up.

Stack trace for Postgres:

MediaWiki\Tests\Maintenance\BackupDumperPageTest::testFullTextPlain
Wikimedia\Rdbms\DBQueryError: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
Query: SELECT  *  FROM "unittest_unittest_profiling"     
Function: MediaWikiTestCase::copyTestData
Error: 42P01 ERROR:  relation "unittest_unittest_profiling" does not exist
LINE 1: ...Case::copyTestData nobody@2cf866a7... */  *  FROM "unittest_...
                                                             ^

/workspace/src/includes/libs/rdbms/database/Database.php:1506
/workspace/src/includes/libs/rdbms/database/Database.php:1476
/workspace/src/includes/libs/rdbms/database/Database.php:1236
/workspace/src/includes/libs/rdbms/database/Database.php:1703
/workspace/src/tests/phpunit/MediaWikiTestCase.php:1894
/workspace/src/tests/phpunit/maintenance/backup_PageTest.php:142
/workspace/src/tests/phpunit/maintenance/backup_PageTest.php:155
/workspace/src/tests/phpunit/MediaWikiTestCase.php:424
/workspace/src/maintenance/doMaintenance.php:94

Stack trace for SQLite:

 Wikimedia\Rdbms\DBQueryError from line 1506 of /workspace/src/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? <br />
Query: SELECT  1  FROM unittest_site_stats    WHERE ss_row_id = '1'  LIMIT 1  <br />
Function: SiteStatsInit::doPlaceholderInit<br />
Error: 1 no such table: unittest_site_stats<br />
<br />
Backtrace:<br />
#0 /workspace/src/includes/libs/rdbms/database/Database.php(1476): Wikimedia\Rdbms\Database-&gt;makeQueryException(string, integer, string, string)<br />
#1 /workspace/src/includes/libs/rdbms/database/Database.php(1236): Wikimedia\Rdbms\Database-&gt;reportQueryError(string, integer, string, string, boolean)<br />
#2 /workspace/src/includes/libs/rdbms/database/Database.php(1703): Wikimedia\Rdbms\Database-&gt;query(string, string)<br />
#3 /workspace/src/includes/libs/rdbms/database/Database.php(1528): Wikimedia\Rdbms\Database-&gt;select(string, string, array, string, array, array)<br />
#4 /workspace/src/includes/SiteStatsInit.php(159): Wikimedia\Rdbms\Database-&gt;selectField(string, string, array, string)<br />
#5 /workspace/src/tests/phpunit/MediaWikiTestCase.php(1310): SiteStatsInit::doPlaceholderInit()<br />
#6 /workspace/src/tests/phpunit/MediaWikiTestCase.php(1797): MediaWikiTestCase-&gt;addCoreDBData()<br />
#7 /workspace/src/tests/phpunit/MediaWikiTestCase.php(430): MediaWikiTestCase-&gt;resetDB(Wikimedia\Rdbms\DatabaseSqlite, array)<br />
#8 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(755): MediaWikiTestCase-&gt;run(MediaWikiTestResult)<br />
#9 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(755): PHPUnit\Framework\TestSuite-&gt;run(MediaWikiTestResult)<br />
#10 /workspace/src/vendor/phpunit/phpunit/src/Framework/TestSuite.php(755): PHPUnit\Framework\TestSuite-&gt;run(MediaWikiTestResult)<br />
#11 /workspace/src/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(545): PHPUnit\Framework\TestSuite-&gt;run(MediaWikiTestResult)<br />
#12 /workspace/src/vendor/phpunit/phpunit/src/TextUI/Command.php(195): PHPUnit\TextUI\TestRunner-&gt;doRun(PHPUnit\Framework\TestSuite, array, boolean)<br />
#13 /workspace/src/tests/phpunit/phpunit.php(90): PHPUnit\TextUI\Command-&gt;run(array, boolean)<br />
#14 /workspace/src/maintenance/doMaintenance.php(94): PHPUnitMaintClass-&gt;execute()<br />
#15 /workspace/src/tests/phpunit/phpunit.php(129): require(string)<br />
#16 {main}<br />

Event Timeline

daniel created this task.Mar 4 2019, 9:49 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 4 2019, 9:49 PM
daniel updated the task description. (Show Details)Mar 4 2019, 9:54 PM

Change 494366 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] [WIP] Make copyTestData on all databases

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

Change 494366 merged by jenkins-bot:
[mediawiki/core@master] Make copyTestData work on postgres

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

Krinkle moved this task from Inbox to PHPUnit on the MediaWiki-Core-Testing board.Apr 5 2019, 3:51 PM
daniel closed this task as Resolved.Apr 15 2019, 3:10 PM