From: Brad Jorsch Date: Tue, 12 Sep 2017 15:48:41 +0000 (-0400) Subject: Improve flaky SiteStatsTest X-Git-Tag: 1.31.0-rc.0~2104^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=d0b093d4bdc5d28eda5d37f5163f0694bd189234;p=lhc%2Fweb%2Fwiklou.git Improve flaky SiteStatsTest SiteStatsTest::testJobsCountGetCached() is somewhat flaky in that if it runs after a test that adds a page (thereby producing htmlCacheUpdate and recentChangesUpdate jobs) but doesn't have the CI framework reset the `page` tables (which has the side effect of clearing all such jobs), it will fail. This change manually clears those jobs so it doesn't depend on test ordering. Change-Id: I1277e633c81b29bda7564fa12d23f13ded7298c7 --- diff --git a/tests/phpunit/includes/SiteStatsTest.php b/tests/phpunit/includes/SiteStatsTest.php index ea476a7cfa..cdbf9fd944 100644 --- a/tests/phpunit/includes/SiteStatsTest.php +++ b/tests/phpunit/includes/SiteStatsTest.php @@ -11,6 +11,11 @@ class SiteStatsTest extends MediaWikiTestCase { $cache = \MediaWiki\MediaWikiServices::getInstance()->getMainWANObjectCache(); $jobq = JobQueueGroup::singleton(); + // Delete EditPage jobs that might have been left behind by other tests + $jobq->get( 'htmlCacheUpdate' )->delete(); + $jobq->get( 'recentChangesUpdate' )->delete(); + $cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) ); + $jobq->push( new NullJob( Title::newMainPage(), [] ) ); $this->assertEquals( 1, SiteStats::jobs(), 'A single job enqueued bumps jobscount stat to 1' );