Skip to content

Commit 01283c4

Browse files
committed
Redis slowlog tests
1 parent 0dc12df commit 01283c4

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Dashboards/Redis/Compatibility/Predis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function execConfig(string $operation, mixed ...$args): mixed {
191191
* @return null|array<int, mixed>
192192
*/
193193
public function getSlowlog(int $count): ?array {
194-
return $this->rawcommand('SLOWLOG', 'GET', $count);
194+
return $this->rawcommand('SLOWLOG', 'GET', (string) $count);
195195
}
196196

197197
public function resetSlowlog(): bool {

tests/Dashboards/Redis/RedisTestCase.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,27 @@ public function testPipelineKeys(): void {
402402
}
403403
}
404404
}
405+
406+
/**
407+
* @throws Exception
408+
*/
409+
public function testSlowlog(): void {
410+
$config_key = 'slowlog-log-slower-than';
411+
$original_config_value = $this->redis->execConfig('GET', $config_key)[$config_key];
412+
413+
try {
414+
$this->redis->resetSlowlog();
415+
$this->redis->execConfig('SET', $config_key, '0');
416+
$this->redis->set('pu-test-slowlog-key', 'some-slow-value');
417+
418+
$slowlog_entries = $this->redis->getSlowlog(10);
419+
$this->assertIsInt($slowlog_entries[1][0]);
420+
$this->assertIsInt($slowlog_entries[1][1]);
421+
$this->assertIsInt($slowlog_entries[1][2]);
422+
$this->assertIsArray($slowlog_entries[1][3]);
423+
} finally {
424+
$this->redis->execConfig('SET', $config_key, $original_config_value);
425+
$this->redis->resetSlowlog();
426+
}
427+
}
405428
}

0 commit comments

Comments
 (0)