Skip to content

Commit ab25ae7

Browse files
Fix PhpRedis session tests to soften timing issues
Rework the session locking unit tests to be less reliant on arbitrary sleep calls which can be very troublesome when running in Travis and especially when running in Travis under valgrind. Additionally, skip multiple newly added Redis 6.2 commands that aren't yet implemented in RedisCluster.
1 parent a6fb815 commit ab25ae7

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

tests/RedisClusterTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public function testConnectException() { return $this->markTestSkipped(); }
4949
public function testTlsConnect() { return $this->markTestSkipped(); }
5050
public function testInvalidAuthArgs() { return $this->markTestSkipped(); }
5151

52+
public function testlMove() { return $this->markTestSkipped(); }
53+
public function testsMisMember() { return $this->markTestSkipped(); }
54+
public function testzDiff() { return $this->markTestSkipped(); }
55+
public function testzDiffStore() { return $this->markTestSkipped(); }
56+
public function testzMscore() { return $this->marktestSkipped(); }
57+
public function testCopy() { return $this->marktestSkipped(); }
58+
5259
/* Session locking feature is currently not supported in in context of Redis Cluster.
5360
The biggest issue for this is the distribution nature of Redis cluster */
5461
public function testSession_lockKeyCorrect() { return $this->markTestSkipped(); }

tests/RedisTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6345,9 +6345,8 @@ public function testSession_lockKeyCorrect()
63456345
ini_get('redis.session.lock_retries') /
63466346
1000000.00);
63476347

6348-
$exist = $this->waitForSessionLockKey($sessionId, $maxwait + 1);
6348+
$exist = $this->waitForSessionLockKey($sessionId, $maxwait);
63496349
$this->assertTrue($exist);
6350-
$this->redis->del($this->sessionPrefix . $sessionId . '_LOCK');
63516350
}
63526351

63536352
public function testSession_lockingDisabledByDefault()
@@ -6372,7 +6371,8 @@ public function testSession_lockReleasedOnClose()
63726371
$this->setSessionHandler();
63736372
$sessionId = $this->generateSessionId();
63746373
$this->startSessionProcess($sessionId, 1, true);
6375-
$this->waitForProcess('startSession.php', 5);
6374+
$sleep = ini_get('redis.session.lock_wait_time') * ini_get('redis.session.lock_retries');
6375+
usleep($sleep + 10000);
63766376
$this->assertFalse($this->redis->exists($this->sessionPrefix . $sessionId . '_LOCK'));
63776377
}
63786378

@@ -6465,7 +6465,6 @@ public function testSession_defaultLockRetryCount()
64656465
}
64666466

64676467
$start = microtime(true);
6468-
$sessionSuccessful = $this->startSessionProcess($sessionId, 0, false, 10, true, 200000, 0);
64696468
$end = microtime(true);
64706469
$elapsedTime = $end - $start;
64716470

@@ -6844,7 +6843,7 @@ private function regenerateSessionId($sessionId, $locking = false, $destroyPrevi
68446843
*
68456844
* @return string
68466845
*/
6847-
private function getPhpCommand($script)
6846+
private static function getPhpCommand($script)
68486847
{
68496848
static $cmd = NULL;
68506849

0 commit comments

Comments
 (0)