Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 13a1827

Browse files
committed
Merge branch 'hotfix/zendframework/zendframework#6303-fix-zendframework/zf2#5144-ttl-tests-stability' into develop
Close zendframework/zendframework#6303 Close zendframework/zendframework#5144 Forward Port zendframework/zendframework#6303 Forward Port zendframework/zendframework#5144
10 parents a5a7547 + 1cd130f + 2f4d84a + c5055d9 + b5302e2 + 9969a8b + ba2ccbf + d057269 + e24be06 + 90850b6 commit 13a1827

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/Storage/Adapter/CommonAdapterTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ public function testHasItemReturnsFalseOnExpiredItem()
225225
$ttl = $capabilities->getTtlPrecision();
226226
$this->_options->setTtl($ttl);
227227

228+
$this->waitForFullSecond();
229+
228230
$this->assertTrue($this->_storage->setItem('key', 'value'));
229231

230232
// wait until the item expired
@@ -300,6 +302,8 @@ public function testGetItemReturnsNullOnExpiredItem()
300302
$ttl = $capabilities->getTtlPrecision();
301303
$this->_options->setTtl($ttl);
302304

305+
$this->waitForFullSecond();
306+
303307
$this->_storage->setItem('key', 'value');
304308

305309
// wait until expired
@@ -543,6 +547,8 @@ public function testSetAndGetExpiredItem()
543547
$ttl = $capabilities->getTtlPrecision();
544548
$this->_options->setTtl($ttl);
545549

550+
$this->waitForFullSecond();
551+
546552
$this->_storage->setItem('key', 'value');
547553

548554
// wait until expired
@@ -581,6 +587,9 @@ public function testSetAndGetExpiredItems()
581587
'key2' => 'value2',
582588
'key3' => 'value3'
583589
);
590+
591+
$this->waitForFullSecond();
592+
584593
$this->assertSame(array(), $this->_storage->setItems($items));
585594

586595
// wait until expired
@@ -828,6 +837,8 @@ public function testTouchItem()
828837

829838
$this->_options->setTtl(2 * $capabilities->getTtlPrecision());
830839

840+
$this->waitForFullSecond();
841+
831842
$this->assertTrue($this->_storage->setItem('key', 'value'));
832843

833844
// sleep 1 times before expire to touch the item
@@ -1000,6 +1011,8 @@ public function testClearExpired()
10001011
$ttl = $capabilities->getTtlPrecision();
10011012
$this->_options->setTtl($ttl);
10021013

1014+
$this->waitForFullSecond();
1015+
10031016
$this->assertTrue($this->_storage->setItem('key1', 'value1'));
10041017

10051018
// wait until the first item expired
@@ -1090,4 +1103,14 @@ public function testGetAvailableSpace()
10901103
$this->assertLessThanOrEqual($totalSpace, $availableSpace);
10911104
}
10921105
}
1106+
1107+
/**
1108+
* This will wait for a full second started
1109+
* to reduce test failures on high load servers
1110+
* @see https://github.com/zendframework/zf2/issues/5144
1111+
*/
1112+
protected function waitForFullSecond()
1113+
{
1114+
usleep((microtime(true)-time()) * 1000000);
1115+
}
10931116
}

0 commit comments

Comments
 (0)