Rework HEXPIRE test inclusion + bump Valkey (#2684)

* Rework `HEXPIRE` test inclusion + bump Valkey

* Add a little `haveCommand` helper which uses `COMMAND INFO` to check
  if a given server has a specific command. This way when we bump valkey
  to an official release that supports the commands we will start
  testing.
* Bump Valkey from 7.2.5 to 8.1.3 which is much newer.

* Rework `haveCommand` to explicitly check for the command name

COMMAND INFO will return the command name as one of the first bits of
data so we can check for it that way.

* Fix incorrect logic
This commit is contained in:
Michael Grunder
2025-08-06 10:08:49 -07:00
committed by GitHub
parent 6e5faf4226
commit b83981aaeb
2 changed files with 12 additions and 5 deletions

View File

@@ -121,7 +121,7 @@ jobs:
- name: Install ValKey
if: matrix.server == 'valkey'
run: |
git clone --depth 1 --branch 7.2.5 https://github.com/valkey-io/valkey.git
git clone --depth 1 --branch 8.1.3 https://github.com/valkey-io/valkey.git
cd valkey && BUILD_TLS=yes sudo make install
- name: Build phpredis

View File

@@ -79,6 +79,13 @@ class Redis_Test extends TestSuite {
$this->is_valkey = $this->detectValKey($info);
}
protected function haveCommand(string $cmd): bool {
$info = $this->redis->command('info', $cmd);
$name = $info[0][0] ?? null;
return $name && strcasecmp($cmd, $name) === 0;
}
protected function minVersionCheck($version) {
return version_compare($this->version, $version) >= 0;
}
@@ -6298,13 +6305,13 @@ class Redis_Test extends TestSuite {
}
public function testHashExpiration() {
if ( ! $this->minVersionCheck('7.4.0'))
if ( ! $this->haveCommand('HEXPIRE'))
$this->markTestSkipped();
$hexpire_cmds = [
'hexpire' => 10,
'hpexpire' => 10000,
'hexpireat' => time() + 10,
'hexpire' => 10,
'hpexpire' => 10000,
'hexpireat' => time() + 10,
'hpexpireat' => time() * 1000 + 10000,
];