8000 Fix flaky test and OBJECT in a pipeline. · phpredis/phpredis@a7f51f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit a7f51f7

Browse files
Fix flaky test and OBJECT in a pipeline.
* We weren't properly passing `z_tab` through to the underlying OBJECT handler, which was causing PhpRedis to crash if you tried to execute the OBJECT command in a pipeline. * Rework the `testTouch` unit test to try and avoid erroneous failures due to CI instance CPU scheduling.
1 parent 954fbab commit a7f51f7

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

library.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,9 +1519,9 @@ redis_object_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval
15191519
ZEND_ASSERT(ctx == PHPREDIS_CTX_PTR || ctx == PHPREDIS_CTX_PTR + 1);
15201520

15211521
if (ctx == PHPREDIS_CTX_PTR) {
1522-
return redis_long_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
1522+
return redis_long_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, z_tab, NULL);
15231523
} else {
1524-
return redis_string_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
1524+
return redis_string_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, z_tab, NULL);
15251525
}
15261526
}
15271527

tests/RedisTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,13 +983,18 @@ public function testTouch() {
983983
$this->redis->del('notakey');
984984

985985
$this->assertTrue($this->redis->mset(['{idle}1' => 'beep', '{idle}2' => 'boop']));
986-
usleep(1100000);
987-
$this->assertTrue($this->redis->object('idletime', '{idle}1') >= 1);
988-
$this->assertTrue($this->redis->object('idletime', '{idle}2') >= 1);
986+
usleep(2100000);
987+
$this->assertTrue($this->redis->object('idletime', '{idle}1') >= 2);
988+
$this->assertTrue($this->redis->object('idletime', '{idle}2') >= 2);
989989

990990
$this->assertEquals(2, $this->redis->touch('{idle}1', '{idle}2', '{idle}notakey'));
991-
$this->assertTrue($this->redis->object('idletime', '{idle}1') == 0);
992-
$this->assertTrue($this->redis->object('idletime', '{idle}2') == 0);
991+
$idle1 = $this->redis->object('idletime', '{idle}1');
992+
$idle2 = $this->redis->object('idletime', '{idle}2');
993+
994+
/* We're not testing if idle is 0 because CPU scheduling on GitHub CI
995+
* potatoes can cause that to erroneously fail. */
996+
$this->assertTrue($idle1 < 2);
997+
$this->assertTrue($idle2 < 2);
993998
}
994999

9951000
public function testKeys()

0 commit comments

Comments
 (0)
0