From: Timo Tijhof Date: Thu, 8 Oct 2015 00:17:13 +0000 (-0700) Subject: objectcache: Fix flaky unit test X-Git-Tag: 1.31.0-rc.0~9493 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=14788f9aab16d36406c92c87b2a91c8ab90840b8;p=lhc%2Fweb%2Fwiklou.git objectcache: Fix flaky unit test Change-Id: Id7d3b75248a42e2e82a51d70a3ee1479f0507685 --- diff --git a/tests/phpunit/includes/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/objectcache/WANObjectCacheTest.php index 742b737733..1fe0bcdc96 100644 --- a/tests/phpunit/includes/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/objectcache/WANObjectCacheTest.php @@ -111,7 +111,10 @@ class WANObjectCacheTest extends MediaWikiTestCase { $this->assertGreaterThanOrEqual( 19, $curTTL, 'Current TTL between 19-20 (overriden)' ); $wasSet = 0; - $v = $cache->getWithSetCallback( $key, $func, 30, array(), array( 'lockTSE' => 5 ) ); + $v = $cache->getWithSetCallback( $key, $func, 30, array(), array( + 'lowTTL' => 0, + 'lockTSE' => 5, + ) ); $this->assertEquals( $v, $value ); $this->assertEquals( 0, $wasSet, "Value not regenerated" ); @@ -239,12 +242,12 @@ class WANObjectCacheTest extends MediaWikiTestCase { $key = wfRandomString(); $priorTime = microtime( true ); - usleep( 1 ); + usleep( 100 ); $t0 = $this->cache->getCheckKeyTime( $key ); $this->assertGreaterThanOrEqual( $priorTime, $t0, 'Check key auto-created' ); $priorTime = microtime( true ); - usleep( 1 ); + usleep( 100 ); $this->cache->touchCheckKey( $key ); $t1 = $this->cache->getCheckKeyTime( $key ); $this->assertGreaterThanOrEqual( $priorTime, $t1, 'Check key created' ); @@ -252,7 +255,7 @@ class WANObjectCacheTest extends MediaWikiTestCase { $t2 = $this->cache->getCheckKeyTime( $key ); $this->assertEquals( $t1, $t2, 'Check key time did not change' ); - usleep( 1 ); + usleep( 100 ); $this->cache->touchCheckKey( $key ); $t3 = $this->cache->getCheckKeyTime( $key ); $this->assertGreaterThan( $t2, $t3, 'Check key time increased' ); @@ -260,7 +263,7 @@ class WANObjectCacheTest extends MediaWikiTestCase { $t4 = $this->cache->getCheckKeyTime( $key ); $this->assertEquals( $t3, $t4, 'Check key time did not change' ); - usleep( 1 ); + usleep( 100 ); $this->cache->resetCheckKey( $key ); $t5 = $this->cache->getCheckKeyTime( $key ); $this->assertGreaterThan( $t4, $t5, 'Check key time increased' );