Page MenuHomePhabricator

Coverage of ApiQuerySiteinfoTest:testContinuation takes 50+ seconds
Closed, ResolvedPublic


When generating mediawiki core code coverage, the suite complains about ApiQuerySiteinfoTest:testContinuation taking too long:

You should really fix these slow tests (>50ms)...
19:19:44  1. 52277ms to run ApiQuerySiteinfoTest:testContinuation

The test has been introduced by @Simetrical with 27d41f442aa2d4f7c1f90b8af9265874aa4239ea

It notably populates $wgUrlProtocols with ~ 86000 entries in order to forge a huge response when doing:

$res = $this->doApiRequest( [
    'action' => 'query',
    'meta' => 'siteinfo',
    'siprop' => 'protocols|languages',
] );

The code thus has to pass through the 86 000 entries which causes a lot of overhead when doing a coverage report.

Running it locally:

$ php tests/phpunit/phpunit.php tests/phpunit/includes/api/ApiQuerySiteinfoTest.php --filter testContinuation
Using PHP 7.3.9-1~deb10u1
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

You should really fix these slow tests (>50ms)...
 1. 231ms to run ApiQuerySiteinfoTest:testContinuation

The test should be refactored, possibly by setting $wgAPIMaxResultSize to a lower value which should be enough to trigger the apiwarn-truncatedresult / testing the continuation.

Event Timeline

Change 539494 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/core@master] Speed up ApiQuerySiteinfoTest:testContinuation

hashar triaged this task as Medium priority.Sep 27 2019, 1:23 PM

Change 539494 merged by jenkins-bot:
[mediawiki/core@master] Speed up ApiQuerySiteinfoTest:testContinuation

Anomie assigned this task to hashar.