From: Antoine Musso Date: Fri, 27 Sep 2019 08:42:56 +0000 (+0200) Subject: Speed up ApiQuerySiteinfoTest:testContinuation X-Git-Tag: 1.34.0-rc.0~75^2 X-Git-Url: http://git.cyclocoop.org/%27%40script%40/ecrire/%22%20.%20parametre_url%28self%28%29%2C?a=commitdiff_plain;h=6d78b45e1bc106f7514e057ecdb5748b8d969d1d;p=lhc%2Fweb%2Fwiklou.git Speed up ApiQuerySiteinfoTest:testContinuation The test fills $wgUrlProtocols with 86000 entries, forging oversized strings which ends up eventually truncated to 100 bytes. The aim is to overflow $wgAPIMaxResultSize to trigger an apiwarn-truncatedresult warning. The test takes 230 ms on my machine and when generating code coverage almost a minute. A faster approach is just to lower the $wgAPIMaxResultSize limit to trigger the warning. Test plan: $ php tests/phpunit/phpunit.php \ tests/phpunit/includes/api/ApiQuerySiteinfoTest.php \ --filter testContinuation Bug: T234016 Change-Id: I3dc96d394d8b98dda8f151d14544b829c92f9b10 --- diff --git a/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php b/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php index dce1a5feef..7f5ee0ca3c 100644 --- a/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php +++ b/tests/phpunit/includes/api/ApiQuerySiteinfoTest.php @@ -665,17 +665,13 @@ class ApiQuerySiteinfoTest extends ApiTestCase { } public function testContinuation() { - // We make lots and lots of URL protocols that are each 100 bytes + // Use $wgUrlProtocols to forge the size of the API query global $wgAPIMaxResultSize, $wgUrlProtocols; - $this->setMwGlobals( 'wgUrlProtocols', [] ); + $protocol = 'foo://'; - // Just under the limit - $chunks = $wgAPIMaxResultSize / 100 - 1; - - for ( $i = 0; $i < $chunks; $i++ ) { - $wgUrlProtocols[] = substr( str_repeat( "$i ", 50 ), 0, 100 ); - } + $this->setMwGlobals( 'wgUrlProtocols', [ $protocol ] ); + $this->setMwGlobals( 'wgAPIMaxResultSize', strlen( $protocol ) ); $res = $this->doApiRequest( [ 'action' => 'query',