Enable stack and cluster tests on 3 latest API versions (#1517)

* Enable stack and cluster tests on 3 latest API versions

* Changed type to string

* Fixed stack tests run against Redis 8.0

* Marked tests as incompatible with 8.0

* Marked more tests as incompatible

* Marked test as incompatible qwith 8.0

* Enable stack and cluster tests for certain PHP versions

* Restrict test to version Redis > 6.2

* Fixed version

* Override stack port for coverage test case

* Added test case for FT.EXPLAIN with dialect 2

* Added additional argument

* Added test cases for new INT8 and UINT8 vectors
This commit is contained in:
Vladyslav Vildanov
2025-03-03 10:31:59 +02:00
committed by GitHub
parent 494148c373
commit b32511926d
21 changed files with 149 additions and 32 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ services:
- standalone
redis-cluster:
image: ${REDIS_CLUSTER_IMAGE_NAME:-redislabs/client-libs-test:7.4.2}
image: ${REDIS_IMAGE_NAME:-redislabs/client-libs-test:7.4.2}
container_name: redis-cluster
environment:
- REDIS_CLUSTER=yes
+24 -6
View File
@@ -45,8 +45,16 @@ jobs:
["6.2"]="6.2.17"
)
# Mapping of redis version to stack version
declare -A redis_stack_version_mapping=(
["7.4"]="rs-7.4.0-v3"
["7.2"]="rs-7.2.0-v15"
["6.2"]="rs-6.2.6-v19"
)
if [[ -v redis_clients_version_mapping[${{ matrix.redis }}] ]]; then
echo "REDIS_IMAGE_NAME=redislabs/client-libs-test:${redis_clients_version_mapping[${{ matrix.redis }}]}" >> $GITHUB_ENV
echo "REDIS_STACK_IMAGE_NAME=redislabs/client-libs-test:${redis_stack_version_mapping[${{ matrix.redis }}]}" >> $GITHUB_ENV
echo "DOCKER_SERVICE=redis-clients" >> $GITHUB_ENV
redis_major_version=$(echo "${{ matrix.redis }}" | grep -oP '^\d+')
@@ -54,7 +62,11 @@ jobs:
# Some configuration options available since Redis > 7
if (( redis_major_version < 7 )); then
echo "REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"" >> $GITHUB_ENV
else
# Since 8.0 modules are bundled with core
echo "REDIS_STACK_SERVER_PORT=6379" >> $GITHUB_ENV
fi
else
echo "REDIS_IMAGE_NAME=redis:${{ matrix.redis }}" >> $GITHUB_ENV
echo "DOCKER_SERVICE=redis-official" >> $GITHUB_ENV
@@ -70,15 +82,17 @@ jobs:
services: ${{ env.DOCKER_SERVICE }}
- name: Start Redis stack image
id: stack_infra
uses: hoverkraft-tech/compose-action@v2.0.1
if: ${{ matrix.redis == '7.4' }}
if: ${{ matrix.redis >= '6.2' && matrix.redis < '8.0' }}
with:
compose-file: .github/docker-compose.yml
services: redis-stack
- name: Start Redis cluster image
id: cluster_infra
uses: hoverkraft-tech/compose-action@v2.0.1
if: ${{ matrix.redis == '7.4' }}
if: ${{ matrix.redis > '4.0' }}
with:
compose-file: .github/docker-compose.yml
services: redis-cluster
@@ -113,12 +127,14 @@ jobs:
run: vendor/bin/phpunit -c phpunit.relay.xml --coverage-php build/cov/coverage-relay.cov --coverage-filter ./src
- name: Run stack tests
if: ${{ matrix.php != '8.4' && matrix.redis == '7.4' }}
if: ${{ (matrix.php != '8.4' || matrix.redis != '7.4') && matrix.redis >= '6.2' }}
run: vendor/bin/phpunit --group realm-stack
- name: Run stack tests with coverage
if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' && steps.stack_infra.conclusion == 'success' }}
run: vendor/bin/phpunit --group realm-stack --coverage-php build/cov/coverage-stack.cov --coverage-filter ./src
env:
REDIS_STACK_SERVER_PORT: 6479
- name: Run stack tests using Relay
if: ${{ matrix.php != '8.4' && matrix.redis == '7.4' }}
@@ -127,14 +143,16 @@ jobs:
- name: Run stack tests using Relay with coverage
if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
run: vendor/bin/phpunit --group realm-stack -c phpunit.relay.xml --coverage-php build/cov/coverage-stack-relay.cov --coverage-filter ./src
env:
REDIS_STACK_SERVER_PORT: 6479
- name: Run tests against cluster
if: ${{ matrix.php != '8.4' && matrix.redis == '7.4' }}
if: ${{ (matrix.php != '8.4' || matrix.redis != '7.4') && steps.cluster_infra.conclusion == 'success' }}
run: |
vendor/bin/phpunit --group cluster
- name: Run tests against cluster with coverage
if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' && steps.cluster_infra.conclusion == 'success' }}
run: |
vendor/bin/phpunit --group cluster --coverage-php build/cov/coverage-cluster.cov --coverage-filter ./src
+1 -1
View File
@@ -41,9 +41,9 @@
<php>
<const name="REDIS_SERVER_HOST" value="127.0.0.1" />
<const name="REDIS_SERVER_PORT" value="6379" />
<const name="REDIS_STACK_SERVER_PORT" value="6479" />
<const name="REDIS_SERVER_DBNUM" value="0" />
<env name="USE_RELAY" value="true" />
<env name="REDIS_STACK_SERVER_PORT" value="6479" />
<!-- Redis Cluster -->
<!-- Only master nodes endpoints included -->
+1 -1
View File
@@ -45,9 +45,9 @@
<php>
<const name="REDIS_SERVER_HOST" value="127.0.0.1" />
<const name="REDIS_SERVER_PORT" value="6379" />
<const name="REDIS_STACK_SERVER_PORT" value="6479" />
<const name="REDIS_SERVER_DBNUM" value="0" />
<env name="USE_RELAY" value="false" />
<env name="REDIS_STACK_SERVER_PORT" value="6479" />
<!-- Redis Cluster -->
<!-- Only master nodes endpoints included -->
+1 -5
View File
@@ -42,11 +42,7 @@ class FTEXPLAIN extends RedisCommand
$arguments[2]->dialect(2);
}
$commandArguments = ['DIALECT', 2];
if (!empty($arguments[2])) {
$commandArguments = $arguments[2]->toArray();
}
$commandArguments = (!empty($arguments[2])) ? $arguments[2]->toArray() : ['DIALECT', 2];
parent::setArguments(array_merge(
[$index, $query],
+1 -1
View File
@@ -176,7 +176,7 @@ abstract class PredisTestCase extends PHPUnit\Framework\TestCase
return [
'scheme' => 'tcp',
'host' => constant('REDIS_SERVER_HOST'),
'port' => ($this->isStackTest()) ? constant('REDIS_STACK_SERVER_PORT') : constant('REDIS_SERVER_PORT'),
'port' => ($this->isStackTest()) ? getenv('REDIS_STACK_SERVER_PORT') : constant('REDIS_SERVER_PORT'),
'database' => constant('REDIS_SERVER_DBNUM'),
];
}
@@ -167,7 +167,6 @@ class FTAGGREGATE_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('index: no such index');
$redis->ftaggregate('index', 'query');
}
@@ -117,7 +117,6 @@ class FTALIASADD_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Unknown index name (or name is an alias itself)');
$redis->ftaliasadd('alias', 'index');
}
@@ -128,7 +128,6 @@ class FTALIASUPDATE_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Unknown index name (or name is an alias itself)');
$redis->ftaliasupdate('alias', 'index');
}
@@ -107,7 +107,6 @@ class FTALTER_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Unknown index name');
$redis->ftalter('alias', [new TextField('field_name')]);
}
@@ -237,7 +237,6 @@ class FTCURSOR_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Cursor not found');
$redis->ftcursor->read('idx', 21412412);
}
@@ -253,7 +252,6 @@ class FTCURSOR_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Cursor does not exist');
$redis->ftcursor->del('idx', 21412412);
}
@@ -93,13 +93,13 @@ class FTDICTDUMP_Test extends PredisCommandTestCase
* @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.4.0
* @requiresRedisVersion <= 7.9.0
*/
public function testThrowsExceptionOnNonExistingDictionary(): void
{
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('could not open dict key');
$redis->ftdictdump('dict');
}
@@ -101,7 +101,6 @@ class FTDROPINDEX_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Unknown Index name');
$redis->ftdropindex('index');
}
@@ -64,6 +64,7 @@ class FTEXPLAIN_Test extends PredisCommandTestCase
* @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 1.0.0
* @requiresRedisVersion <= 7.9.0
*/
public function testExplainReturnsExecutionPlanForGivenQuery(): void
{
@@ -116,7 +117,7 @@ EOT;
* @group connected
* @return void
* @requiresRediSearchVersion >= 2.8.0
* @requiresRedisVersion >= 7.5.0
* @requiresRedisVersion <= 7.9.0
*/
public function testExplainReturnsExecutionPlanForGivenQueryResp3(): void
{
@@ -158,7 +159,48 @@ EOT;
$this->assertEquals('OK', $redis->ftcreate('index', $schema));
$this->assertEquals(
$expectedResponse,
$redis->ftexplain('index', '(foo bar)|(hello world) @date:[100 200]|@date:[500 +inf]')
$redis->ftexplain(
'index',
'(foo bar)|(hello world) @date:[100 200]|@date:[500 +inf]',
(new ExplainArguments())->dialect(1)
)
);
}
/**
* @group connected
* @return void
* @requiresRediSearchVersion >= 2.8.0
* @requiresRedisVersion > 7.3.0
*/
public function testExplainReturnsExecutionPlanForGivenQueryWithDialect2(): void
{
$redis = $this->getClient();
$expectedResponse = <<<EOT
INTERSECT {
@name:UNION {
@name:james
@name:+jame(expanded)
@name:jame(expanded)
}
UNION {
brown
+brown(expanded)
}
}
EOT;
$schema = [new TextField('name')];
$this->assertEquals('OK', $redis->ftcreate('index', $schema));
$this->assertEquals(
$expectedResponse,
$redis->ftexplain(
'index',
'@name: James Brown',
(new ExplainArguments())->language()
)
);
}
@@ -173,7 +215,6 @@ EOT;
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('index: no such index');
$redis->ftexplain('index', 'query');
}
@@ -102,7 +102,6 @@ class FTPROFILE_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('index: no such index');
$redis->ftprofile('index', (new ProfileArguments())->search()->query('query'));
}
@@ -236,6 +236,78 @@ class FTSEARCH_Test extends PredisCommandTestCase
);
}
/**
* @group connected
* @group relay-resp3
* @return void
* @requiresRedisVersion >= 7.9.0
*/
public function testVectorSearchWithInt8Types(): void
{
$redis = $this->getClient();
$this->assertEquals('OK', $redis->ftcreate('test', [
new VectorField(
'v', 'HNSW',
['TYPE', 'INT8', 'DIM', 2, 'DISTANCE_METRIC', 'L2']
),
]));
$this->sleep(0.1);
$a = [1.5, 10];
$b = [123, 100];
$c = [1, 1];
$redis->hset('a', 'v', pack('c*', ...$a));
$redis->hset('b', 'v', pack('c*', ...$b));
$redis->hset('c', 'v', pack('c*', ...$c));
$searchArguments = new SearchArguments();
$searchArguments->params(['vec', pack('c*', ...$a)]);
$this->assertEquals(
2,
$redis->ftsearch('test', '*=>[KNN 2 @v $vec]', $searchArguments)[0]
);
}
/**
* @group connected
* @group relay-resp3
* @return void
* @requiresRedisVersion >= 7.9.0
*/
public function testVectorSearchWithUInt8Types(): void
{
$redis = $this->getClient();
$this->assertEquals('OK', $redis->ftcreate('test', [
new VectorField(
'v', 'HNSW',
['TYPE', 'UINT8', 'DIM', 2, 'DISTANCE_METRIC', 'L2']
),
]));
$this->sleep(0.1);
$a = [1.5, 10];
$b = [123, 100];
$c = [1, 1];
$redis->hset('a', 'v', pack('C*', ...$a));
$redis->hset('b', 'v', pack('C*', ...$b));
$redis->hset('c', 'v', pack('C*', ...$c));
$searchArguments = new SearchArguments();
$searchArguments->params(['vec', pack('C*', ...$a)]);
$this->assertEquals(
2,
$redis->ftsearch('test', '*=>[KNN 2 @v $vec]', $searchArguments)[0]
);
}
public function argumentsProvider(): array
{
return [
@@ -123,11 +123,11 @@ class FTSUGGET_Test extends PredisCommandTestCase
* @return void
* @requiresRediSearchVersion >= 1.0.0
*/
public function testGetReturnsNullOnNonExistingKey(): void
public function testGetReturnsEmptyArrayOnNonExistingKey(): void
{
$redis = $this->getClient();
$this->assertNull($redis->ftsugget('key', 'hel'));
$this->assertEmpty($redis->ftsugget('key', 'hel'));
}
public function argumentsProvider(): array
@@ -118,7 +118,6 @@ class FTSYNDUMP_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Unknown index name');
$redis->ftsyndump('index');
}
@@ -137,7 +137,6 @@ class FTSYNUPDATE_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Unknown index name');
$redis->ftsynupdate(
'index',
@@ -137,7 +137,6 @@ class FTTAGVALS_Test extends PredisCommandTestCase
$redis = $this->getClient();
$this->expectException(ServerException::class);
$this->expectExceptionMessage('Unknown Index name');
$redis->fttagvals('index', 'fieldName');
}
@@ -64,6 +64,7 @@ class TSINFO_Test extends PredisCommandTestCase
* @group relay-resp3
* @return void
* @requiresRedisTimeSeriesVersion >= 1.0.0
* @requiresRedisVersion > 6.3.0
*/
public function testReturnsInformationAboutGivenTimeSeries(): void
{