Added test coverage for compatibility with Redis 8.0 (#1513)

* Added testing with 8.0

* Removed old service

* Moved checkout stage above image

* Changed service name

* Override config options for Redis < 7

* Exported to github env

* Print major version output

* Added double quotes

* Test fixes

* Merge cluster and standalone infrastructure

* Removed separate cluster job and merge together with standalone

* Merge stack tests into main test job

* Fixed annotation condition

* tweaks

* Moved docker-compose.yml to root folder

* Added compose file to expected

* fixed in v0.10.1

* move docker file

* Added -all profile in docker-compose

* Removed redis official image, reduce test matrix, moved docker-compose.yml

* Revert docker-compose moving

* Added test coverage to verify compatibility with 8.0

* Mark tests as relay-incompatible

* Codestyle fix

* Marked as relay-incompatible

---------

Co-authored-by: Till Krüss <tillkruss@users.noreply.github.com>
This commit is contained in:
Vladyslav Vildanov
2025-02-24 19:22:45 +02:00
committed by GitHub
parent 9a22450a65
commit 02e2a7e1cc
5 changed files with 231 additions and 0 deletions
+1
View File
@@ -15,6 +15,7 @@ namespace Predis\Command\Redis\Container;
use Predis\Response\Status;
/**
* @method array cat(string $category = null)
* @method Status dryRun(string $username, string $command, ...$arguments)
* @method array getUser(string $username)
* @method Status setUser(string $username, string ...$rules)
+4
View File
@@ -13,8 +13,12 @@
namespace Predis\Command\Redis\Search;
use Predis\Command\Command as RedisCommand;
use Predis\Command\Redis\CONFIG;
/**
* @deprecated FT.CONFIG GET and SET is deprecated since Redis 8.0.
* @see CONFIG if you want to manipulate search configuration
*
* @see https://redis.io/commands/ft.config-get/
* @see https://redis.io/commands/ft.config-set/
*
+169
View File
@@ -12,6 +12,7 @@
namespace Predis\Command\Redis;
use Predis\Command\Argument\Search\SchemaFields\TextField;
use Predis\Response\ServerException;
class ACL_Test extends PredisCommandTestCase
@@ -132,6 +133,174 @@ class ACL_Test extends PredisCommandTestCase
}
}
/**
* @group connected
* @return void
* @requiresRedisVersion >= 7.9.0
*/
public function testModuleCategoriesAppearsInListOfAllCategories(): void
{
$redis = $this->getClient();
$allCategories = $redis->acl->cat();
foreach (['bloom', 'cuckoo', 'cms', 'topk', 'tdigest', 'search', 'timeseries', 'json'] as $category) {
$this->assertContains($category, $allCategories);
}
}
/**
* @group connected
* @group relay-incompatible
* @return void
* @requiresRedisVersion >= 7.9.0
*/
public function testSetModuleCommandPrivileges(): void
{
$redis = $this->getClient();
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'reset',
'nopass',
'on'
)
);
$this->assertEquals('OK', $redis->auth('testUser', ''));
$this->expectException(ServerException::class);
$redis->ftcreate('test', [new TextField('foo')]);
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+ft.create',
'+ft.search'
)
);
$this->assertEquals('OK', $redis->ftcreate('test', [new TextField('foo')]));
$this->assertEmpty($redis->ftsearch('test', '*'));
$this->expectException(ServerException::class);
$redis->jsonset('test', '$', '{"key":"value"}');
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+json.set'
)
);
$this->assertEquals('OK', $redis->jsonset('test', '$', '{"key":"value"}'));
$this->expectException(ServerException::class);
$redis->bfadd('test', 'value');
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+bf.add'
)
);
$this->assertEquals(1, $redis->bfadd('test', 'value'));
$this->expectException(ServerException::class);
$redis->tsadd('test', time(), 0.01);
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+ts.add'
)
);
$this->assertEquals(1, $redis->tsadd('test', time(), 0.01));
}
/**
* @group connected
* @group relay-incompatible
* @return void
* @requiresRedisVersion >= 7.9.0
*/
public function testSetModuleCategoryPrivileges(): void
{
$redis = $this->getClient();
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'reset',
'nopass',
'on'
)
);
$this->assertEquals('OK', $redis->auth('testUser', ''));
$this->expectException(ServerException::class);
$redis->ftcreate('test', [new TextField('foo')]);
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+@search'
)
);
$this->assertEquals('OK', $redis->ftcreate('test', [new TextField('foo')]));
$this->assertEmpty($redis->ftsearch('test', '*'));
$this->expectException(ServerException::class);
$redis->jsonset('test', '$', '{"key":"value"}');
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+@json'
)
);
$this->assertEquals('OK', $redis->jsonset('test', '$', '{"key":"value"}'));
$this->expectException(ServerException::class);
$redis->bfadd('test', 'value');
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+@bloom'
)
);
$this->assertEquals(1, $redis->bfadd('test', 'value'));
$this->expectException(ServerException::class);
$redis->tsadd('test', time(), 0.01);
$this->assertEquals(
'OK',
$redis->acl->setUser(
'testUser',
'+@timeseries'
)
);
$this->assertEquals(1, $redis->tsadd('test', time(), 0.01));
}
/**
* @group connected
* @return void
@@ -12,6 +12,8 @@
namespace Predis\Command\Redis;
use Predis\Response\ServerException;
/**
* @group commands
* @group realm-server
@@ -137,6 +139,48 @@ class CONFIG_Test extends PredisCommandTestCase
$redis->config('SET', 'loglevel', $previous['loglevel']);
}
/**
* @group connected
* @group relay-incompatible
* @requiresRedisVersion >= 7.9.0
*/
public function testOverrideDefaultDialectWithConfigCommand()
{
$redis = $this->getClient();
$default_dialect = (int) $redis
->config('GET', 'search-default-dialect')['search-default-dialect'];
$this->assertEquals('OK', $redis->config('SET', 'search-default-dialect', 2));
$this->assertEquals(2, (int) $redis->ftconfig->get('DEFAULT_DIALECT')[0][1]);
$this->assertEquals(2,
(int) $redis->config('GET', 'search-default-dialect')['search-default-dialect']);
$this->assertEquals(
'OK',
$redis->config('SET', 'search-default-dialect', $default_dialect)
);
}
/**
* @group connected
* @requiresRedisVersion >= 7.9.0
*/
public function testSetGetSearchConfiguration()
{
$redis = $this->getClient();
$this->assertGreaterThan(0,
(int) $redis->config('GET', 'search-timeout')['search-timeout']);
$this->assertGreaterThanOrEqual(0,
(int) $redis->config('GET', 'ts-retention-policy')['ts-retention-policy']);
$this->assertGreaterThanOrEqual(0,
(int) $redis->config('GET', 'bf-error-rate')['bf-error-rate']);
$this->assertGreaterThan(0,
(int) $redis->config('GET', 'cf-initial-size')['cf-initial-size']);
$this->expectException(ServerException::class);
$redis->config('SET', 'search-max-doctablesize', 10000);
}
/**
* @group connected
* @requiresRedisVersion >= 2.0.0
+13
View File
@@ -313,6 +313,19 @@ BUFFER;
$this->assertArrayHasKey('redis_version', $info['Server'] ?? $info);
}
/**
* @group connected
* @requiresRedisVersion >= 7.9.0
*/
public function testExposeSearchInformation(): void
{
$redis = $this->getClient();
$this->assertArrayHasKey('search', $redis->info('modules')['Modules']);
$this->assertNotEmpty($redis->info('search'));
$this->assertArrayHasKey('search', $redis->info('everything')['Modules']);
}
/**
* @group connected
* @requiresRedisVersion < 2.6.0