From df14e11c3a047217a16ad2430c1587a583c2268c Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Mon, 24 Jul 2023 10:21:43 +0300 Subject: [PATCH 01/23] Added support for tests running against redis cluster (#1236) * Added support for tests running against redis cluster * Test coverage * Added comment about master nodes * Codestyle fix * Revert changes * Revert DBNUM * Added cluster endpoints to relay tests env configuration * Exclude cluster tests from relay tests environment * Removed TODO comment * Changed cluster image version to unstable * Updated configuration to match unstable cluster * Fixed path * Updated cluster CI configuration * Removed redundant flag * Removed backslash * Updated file path * Updated file path variable * Added docker cluster initialization as additional step * Run cluster tests as separate workflow * Codestyle fixes * Updated exported files * Added additional timeout so cluster image could be settled * Added support for different cluster image, use docker compose for cluster tests CI * Remove unused flag * Removed variable from volume path * Added sleep timeout to allow docker setup after running * Added timeout before tests run * Updated linter settings * Include indent changes for.sh files * Added missing coverage * Revert expected files and mark docker folder as exclusion * Specify folder itself as excluded * Moved cluster tests as separate job in tests.yml * Updated name to contain cluster word --------- Co-authored-by: Chayim --- .codespellrc | 2 +- .editorconfig | 2 +- .github/workflows/linters.yml | 2 +- .github/workflows/tests.yml | 43 +++++++++++++++++++ docker/unstable_cluster/Dockerfile | 7 +++ docker/unstable_cluster/create_cluster.sh | 47 +++++++++++++++++++++ docker/unstable_cluster/docker-compose.yml | 17 ++++++++ docker/unstable_cluster/redis.conf | 9 ++++ phpunit.relay.xml | 5 +++ phpunit.xml.dist | 5 +++ src/Cluster/ClusterStrategy.php | 14 ++++++ tests/PHPUnit/PredisCommandTestCase.php | 6 ++- tests/PHPUnit/PredisTestCase.php | 45 ++++++++++++++++++++ tests/Predis/Cluster/PredisStrategyTest.php | 19 +++++++++ tests/Predis/Cluster/RedisStrategyTest.php | 19 +++++++++ tests/Predis/Command/Redis/SET_Test.php | 13 ++++++ 16 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 docker/unstable_cluster/Dockerfile create mode 100644 docker/unstable_cluster/create_cluster.sh create mode 100644 docker/unstable_cluster/docker-compose.yml create mode 100644 docker/unstable_cluster/redis.conf diff --git a/.codespellrc b/.codespellrc index 0e95e105c..70f773561 100644 --- a/.codespellrc +++ b/.codespellrc @@ -3,4 +3,4 @@ skip=./.git check-hidden= check-filenames= builtin=clear,rare,informal,usage,code,names -ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove,SUGGET,sugget +ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove,SUGGET,sugget,ro diff --git a/.editorconfig b/.editorconfig index 0764720be..9cffd80e7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,7 +14,7 @@ block_comment_end = */ [*.php] max_line_length = 150 -[*.{md,yml,yaml,neon}] +[*.{md,yml,yaml,neon,sh}] indent_size = 2 [tests/**.php] diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index b6d481b08..1e22c8998 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -136,7 +136,7 @@ jobs: EXPECTED="LICENSE,README.md,autoload.php,composer.json" CURRENT="$( git archive HEAD \ - | tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" \ + | tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" --exclude="docker" --exclude="docker/*" \ | paste --serial --delimiters="," )" echo "CURRENT =${CURRENT}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b5259142d..44f3b7f3a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -78,3 +78,46 @@ jobs: run: | wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar" php ./php-coveralls.phar -v + + predis-cluster: + + name: PHP ${{ matrix.php }} (Redis Cluster latest) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + - '8.2' + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Run redis cluster + uses: isbang/compose-action@v1.4.1 + with: + compose-file: "./docker/unstable_cluster/docker-compose.yml" + + - name: Setup PHP with Composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: relay + coverage: ${{ (matrix.php == '8.1') && 'xdebug' || 'none' }} + + - name: Install Composer dependencies + uses: ramsey/composer-install@v2 + with: + dependency-versions: highest + composer-options: ${{ matrix.php == '8.0' && '--ignore-platform-reqs' || '' }} + + - name: Run tests against cluster + run: | + sleep 5 # Timeout to make sure that docker image is setup + vendor/bin/phpunit --group cluster diff --git a/docker/unstable_cluster/Dockerfile b/docker/unstable_cluster/Dockerfile new file mode 100644 index 000000000..a434dddce --- /dev/null +++ b/docker/unstable_cluster/Dockerfile @@ -0,0 +1,7 @@ +FROM redis/redis-stack-server:latest as rss + +COPY create_cluster.sh /create_cluster.sh +RUN ls -R /opt/redis-stack +RUN chmod a+x /create_cluster.sh + +ENTRYPOINT [ "/create_cluster.sh"] diff --git a/docker/unstable_cluster/create_cluster.sh b/docker/unstable_cluster/create_cluster.sh new file mode 100644 index 000000000..b000a2ad7 --- /dev/null +++ b/docker/unstable_cluster/create_cluster.sh @@ -0,0 +1,47 @@ +#! /bin/bash + +mkdir -p /nodes +touch /nodes/nodemap +if [ -z ${START_PORT} ]; then + START_PORT=6372 +fi +if [ -z ${END_PORT} ]; then + END_PORT=6377 +fi +if [ ! -z "$3" ]; then + START_PORT=$2 + START_PORT=$3 +fi +echo "STARTING: ${START_PORT}" +echo "ENDING: ${END_PORT}" + +for PORT in `seq ${START_PORT} ${END_PORT}`; do + mkdir -p /nodes/$PORT + if [[ -e /redis.conf ]]; then + cp /redis.conf /nodes/$PORT/redis.conf + else + touch /nodes/$PORT/redis.conf + fi + cat << EOF >> /nodes/$PORT/redis.conf +port ${PORT} +cluster-enabled yes +daemonize yes +logfile /redis.log +dir /nodes/$PORT +EOF + + set -x + /opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf + sleep 1 + if [ $? -ne 0 ]; then + echo "Redis failed to start, exiting." + continue + fi + echo 127.0.0.1:$PORT >> /nodes/nodemap +done +if [ -z "${REDIS_PASSWORD}" ]; then + echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 +else + echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 +fi +tail -f /redis.log diff --git a/docker/unstable_cluster/docker-compose.yml b/docker/unstable_cluster/docker-compose.yml new file mode 100644 index 000000000..2829da39a --- /dev/null +++ b/docker/unstable_cluster/docker-compose.yml @@ -0,0 +1,17 @@ +version: "3.9" +services: + cluster: + container_name: redis-cluster + build: + context: . + dockerfile: Dockerfile + ports: + - "6372:6372" + - "6373:6373" + - "6374:6374" + - "6375:6375" + - "6376:6376" + - "6377:6378" + volumes: + - "./redis.conf:/redis.conf:ro" + diff --git a/docker/unstable_cluster/redis.conf b/docker/unstable_cluster/redis.conf new file mode 100644 index 000000000..71928253e --- /dev/null +++ b/docker/unstable_cluster/redis.conf @@ -0,0 +1,9 @@ +# Redis Cluster config file will be shared across all nodes. +# Do not change the following configurations that are already set: +# port, cluster-enabled, daemonize, logfile, dir +protected-mode no +loadmodule /opt/redis-stack/lib/redisearch.so +loadmodule /opt/redis-stack/lib/redisgraph.so +loadmodule /opt/redis-stack/lib/redistimeseries.so +loadmodule /opt/redis-stack/lib/rejson.so +loadmodule /opt/redis-stack/lib/redisbloom.so diff --git a/phpunit.relay.xml b/phpunit.relay.xml index 731f29c27..f8926a4fb 100644 --- a/phpunit.relay.xml +++ b/phpunit.relay.xml @@ -24,6 +24,7 @@ realm-stack ext-curl ext-phpiredis + cluster @@ -38,5 +39,9 @@ + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d47afa8dd..5ec9da95a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -33,6 +33,7 @@ ext-relay ext-curl ext-phpiredis + cluster @@ -51,5 +52,9 @@ + + + + diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index b12b8b0fe..8b69ffdee 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -53,6 +53,7 @@ protected function getDefaultCommands() 'SORT' => [$this, 'getKeyFromSortCommand'], 'DUMP' => $getKeyFromFirstArgument, 'RESTORE' => $getKeyFromFirstArgument, + 'FLUSHDB' => [$this, 'getFakeKey'], /* commands operating on string values */ 'APPEND' => $getKeyFromFirstArgument, @@ -163,6 +164,9 @@ protected function getDefaultCommands() 'EVAL' => [$this, 'getKeyFromScriptingCommands'], 'EVALSHA' => [$this, 'getKeyFromScriptingCommands'], + /* server */ + 'INFO' => [$this, 'getFakeKey'], + /* commands performing geospatial operations */ 'GEOADD' => $getKeyFromFirstArgument, 'GEOHASH' => $getKeyFromFirstArgument, @@ -216,6 +220,16 @@ public function setCommandHandler($commandID, $callback = null) $this->commands[$commandID] = $callback; } + /** + * Get fake key for commands with no key argument. + * + * @return string + */ + protected function getFakeKey(): string + { + return 'key'; + } + /** * Extracts the key from the first argument of a command instance. * diff --git a/tests/PHPUnit/PredisCommandTestCase.php b/tests/PHPUnit/PredisCommandTestCase.php index 9aa6f5167..1a13801e5 100644 --- a/tests/PHPUnit/PredisCommandTestCase.php +++ b/tests/PHPUnit/PredisCommandTestCase.php @@ -61,7 +61,11 @@ public function getClient(bool $flushdb = true): Client ); } - $client = $this->createClient(null, null, $flushdb); + if ($this->isClusterTest()) { + $client = $this->createClient(null, ['cluster' => 'redis'], $flushdb); + } else { + $client = $this->createClient(null, null, $flushdb); + } return $client; } diff --git a/tests/PHPUnit/PredisTestCase.php b/tests/PHPUnit/PredisTestCase.php index d67829e87..3dcdc1a4e 100644 --- a/tests/PHPUnit/PredisTestCase.php +++ b/tests/PHPUnit/PredisTestCase.php @@ -153,6 +153,10 @@ public static function assertMatchesRegularExpression(string $pattern, string $s */ protected function getDefaultParametersArray(): array { + if ($this->isClusterTest()) { + return $this->prepareClusterEndpoints(); + } + return [ 'scheme' => 'tcp', 'host' => constant('REDIS_SERVER_HOST'), @@ -237,6 +241,15 @@ protected function createClient(array $parameters = null, array $options = null, getenv('USE_RELAY') ? ['connections' => 'relay'] : [] ); + if ($this->isClusterTest()) { + $options = array_merge( + [ + 'cluster' => 'redis', + ], + $options + ); + } + $client = new Client($parameters, $options); $client->connect(); @@ -537,4 +550,36 @@ protected function markTestSkippedOnCIEnvironment(string $message = 'Test skippe $this->markTestSkipped($message); } } + + /** + * Check annotations if it's matches to cluster test scenario. + * + * @return bool + */ + protected function isClusterTest(): bool + { + $annotations = TestUtil::parseTestMethodAnnotations( + get_class($this), + $this->getName(false) + ); + + return isset($annotations['method']['requiresRedisVersion'], $annotations['method']['group']) + && !empty($annotations['method']['requiresRedisVersion']) + && in_array('connected', $annotations['method']['group'], true) + && in_array('cluster', $annotations['method']['group'], true); + } + + /** + * Parse comma-separated cluster endpoints and convert them into tcp strings. + * + * @return array + */ + protected function prepareClusterEndpoints(): array + { + $endpoints = explode(',', constant('REDIS_CLUSTER_ENDPOINTS')); + + return array_map(static function (string $elem) { + return 'tcp://' . $elem; + }, $endpoints); + } } diff --git a/tests/Predis/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php index fbf7922c8..82637f387 100644 --- a/tests/Predis/Cluster/PredisStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -106,6 +106,21 @@ public function testInterleavedKeysCommands(): void } } + /** + * @group disconnected + */ + public function testFakeKeyCommandsWithOneKey(): void + { + $strategy = $this->getClusterStrategy(); + $commands = $this->getCommandFactory(); + $arguments = []; + + foreach ($this->getExpectedCommands('keys-fake') as $commandID) { + $command = $commands->create($commandID, $arguments); + $this->assertNotNull($strategy->getSlot($command), $commandID); + } + } + /** * @group disconnected */ @@ -327,6 +342,7 @@ protected function getExpectedCommands(string $type = null): array 'SORT' => 'variable', 'DUMP' => 'keys-first', 'RESTORE' => 'keys-first', + 'FLUSHDB' => 'keys-fake', /* commands operating on string values */ 'APPEND' => 'keys-first', @@ -437,6 +453,9 @@ protected function getExpectedCommands(string $type = null): array 'EVAL' => 'keys-script', 'EVALSHA' => 'keys-script', + /* server */ + 'INFO' => 'keys-fake', + /* commands performing geospatial operations */ 'GEOADD' => 'keys-first', 'GEOHASH' => 'keys-first', diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php index dd570d531..2c31da119 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -134,6 +134,21 @@ public function testInterleavedKeysCommandsWithMoreKeys(): void } } + /** + * @group disconnected + */ + public function testFakeKeyCommandsWithOneKey(): void + { + $strategy = $this->getClusterStrategy(); + $commands = $this->getCommandFactory(); + $arguments = []; + + foreach ($this->getExpectedCommands('keys-fake') as $commandID) { + $command = $commands->create($commandID, $arguments); + $this->assertNotNull($strategy->getSlot($command), $commandID); + } + } + /** * @group disconnected */ @@ -350,6 +365,7 @@ protected function getExpectedCommands(string $type = null): array 'SORT' => 'keys-first', // TODO 'DUMP' => 'keys-first', 'RESTORE' => 'keys-first', + 'FLUSHDB' => 'keys-fake', /* commands operating on string values */ 'APPEND' => 'keys-first', @@ -460,6 +476,9 @@ protected function getExpectedCommands(string $type = null): array 'EVAL' => 'keys-script', 'EVALSHA' => 'keys-script', + /* server */ + 'INFO' => 'keys-fake', + /* commands performing geospatial operations */ 'GEOADD' => 'keys-first', 'GEOHASH' => 'keys-first', diff --git a/tests/Predis/Command/Redis/SET_Test.php b/tests/Predis/Command/Redis/SET_Test.php index 5127e9e16..107ac9adb 100644 --- a/tests/Predis/Command/Redis/SET_Test.php +++ b/tests/Predis/Command/Redis/SET_Test.php @@ -134,4 +134,17 @@ public function testSetStringValueWithModifierXX(): void $this->assertEquals('OK', $redis->set('foo', 'barbar', 'XX')); $this->assertNull($redis->set('foofoo', 'barbar', 'XX')); } + + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 3.0.0 + * @return void + */ + public function testSetStringValueInClusterMode(): void + { + $redis = $this->getClient(); + + $this->assertEquals('OK', $redis->set('foo', 'bar')); + } } From a3311d6869c9e881ce4cb2e8b642f6b274227151 Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Thu, 3 Aug 2023 09:03:21 +0300 Subject: [PATCH 02/23] 2.2.1 version changes (#1349) --- VERSION | 2 +- src/Client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 17831900d..c043eea77 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.0-RC1 +2.2.1 diff --git a/src/Client.php b/src/Client.php index 0517a0870..41bd1f3a3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -53,7 +53,7 @@ */ class Client implements ClientInterface, IteratorAggregate { - public const VERSION = '2.2.0-RC1'; + public const VERSION = '2.2.1'; /** @var OptionsInterface */ private $options; From 4172d2265f843f298ed079e8e704d45481bb03a3 Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Thu, 3 Aug 2023 09:04:04 +0300 Subject: [PATCH 03/23] Client set name and version on connection (#1347) * Added client metadata on server connection * Added try...catch around server exception to supress CLIENT command errors * Added exclusion for Relay connection --- src/Connection/AbstractConnection.php | 13 ++++ src/Connection/Factory.php | 11 ++++ src/Connection/StreamConnection.php | 4 +- tests/Predis/ClientTest.php | 14 +++++ tests/Predis/Connection/FactoryTest.php | 59 ++++++++++++++++--- .../Connection/StreamConnectionTest.php | 19 ++++++ 6 files changed, 110 insertions(+), 10 deletions(-) diff --git a/src/Connection/AbstractConnection.php b/src/Connection/AbstractConnection.php index 5383924cc..3273f3866 100644 --- a/src/Connection/AbstractConnection.php +++ b/src/Connection/AbstractConnection.php @@ -14,6 +14,7 @@ use InvalidArgumentException; use Predis\Command\CommandInterface; +use Predis\Command\RawCommand; use Predis\CommunicationException; use Predis\Protocol\ProtocolException; @@ -27,6 +28,10 @@ abstract class AbstractConnection implements NodeConnectionInterface private $cachedId; protected $parameters; + + /** + * @var RawCommand[] + */ protected $initCommands = []; /** @@ -101,6 +106,14 @@ public function addConnectCommand(CommandInterface $command) $this->initCommands[] = $command; } + /** + * {@inheritdoc} + */ + public function getInitCommands(): array + { + return $this->initCommands; + } + /** * {@inheritdoc} */ diff --git a/src/Connection/Factory.php b/src/Connection/Factory.php index ad472360c..c78c6d406 100644 --- a/src/Connection/Factory.php +++ b/src/Connection/Factory.php @@ -13,6 +13,7 @@ namespace Predis\Connection; use InvalidArgumentException; +use Predis\Client; use Predis\Command\RawCommand; use ReflectionClass; use UnexpectedValueException; @@ -174,6 +175,16 @@ protected function prepareConnection(NodeConnectionInterface $connection) ); } + if (!$connection instanceof RelayConnection) { + $connection->addConnectCommand( + new RawCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis']) + ); + + $connection->addConnectCommand( + new RawCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION]) + ); + } + if (isset($parameters->database) && strlen($parameters->database)) { $connection->addConnectCommand( new RawCommand('SELECT', [$parameters->database]) diff --git a/src/Connection/StreamConnection.php b/src/Connection/StreamConnection.php index e0e077c95..2fe307067 100644 --- a/src/Connection/StreamConnection.php +++ b/src/Connection/StreamConnection.php @@ -231,7 +231,9 @@ public function connect() foreach ($this->initCommands as $command) { $response = $this->executeCommand($command); - if ($response instanceof ErrorResponseInterface) { + if ($response instanceof ErrorResponseInterface && $command->getId() === 'CLIENT') { + // Do nothing on CLIENT SETINFO command failure + } elseif ($response instanceof ErrorResponseInterface) { $this->onConnectionError("`{$command->getId()}` failed: {$response->getMessage()}", 0); } } diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index 04bac9030..fba37d988 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -1253,6 +1253,20 @@ public function testGetIteratorWithNonTraversableConnectionNoException(): void $this->assertSame('127.0.0.1:6381', $iterator->key()); } + /** + * @group connected + * @requiresRedisVersion >= 7.2.0 + */ + public function testSetClientInfoOnConnection(): void + { + $client = new Client($this->getParameters()); + $libName = $client->client('LIST')[0]['lib-name']; + $libVer = $client->client('LIST')[0]['lib-ver']; + + $this->assertSame('predis', $libName); + $this->assertSame(Client::VERSION, $libVer); + } + // ******************************************************************** // // ---- HELPER METHODS ------------------------------------------------ // // ******************************************************************** // diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php index 4d98dd6f6..5e64497b7 100644 --- a/tests/Predis/Connection/FactoryTest.php +++ b/tests/Predis/Connection/FactoryTest.php @@ -12,6 +12,8 @@ namespace Predis\Connection; +use Predis\Client; +use Predis\Command\RawCommand; use PredisTestCase; use ReflectionObject; use stdClass; @@ -302,10 +304,12 @@ public function testCreateConnectionWithInitializationCommands(): void ->method('getParameters') ->willReturn($parameters); $connection - ->expects($this->exactly(2)) + ->expects($this->exactly(4)) ->method('addConnectCommand') ->withConsecutive( [$this->isRedisCommand('AUTH', ['foobar'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])], [$this->isRedisCommand('SELECT', ['0'])] ); @@ -331,9 +335,13 @@ public function testCreateConnectionWithPasswordAndNoUsernameAddsInitializationC $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->once()) + $connection->expects($this->exactly(3)) ->method('addConnectCommand') - ->with($this->isRedisCommand('AUTH', ['foobar'])); + ->withConsecutive( + [$this->isRedisCommand('AUTH', ['foobar'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] + ); $factory = new Factory(); @@ -358,9 +366,13 @@ public function testCreateConnectionWithPasswordAndUsernameAddsInitializationCom $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->once()) + $connection->expects($this->exactly(3)) ->method('addConnectCommand') - ->with($this->isRedisCommand('AUTH', ['myusername', 'foobar'])); + ->withConsecutive( + [$this->isRedisCommand('AUTH', ['myusername', 'foobar'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] + ); $factory = new Factory(); @@ -384,8 +396,12 @@ public function testCreateConnectionWithUsernameAndNoPasswordDoesNotAddInitializ $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->never()) - ->method('addConnectCommand'); + $connection->expects($this->exactly(2)) + ->method('addConnectCommand') + ->withConsecutive( + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] + ); $factory = new Factory(); @@ -410,8 +426,12 @@ public function testCreateConnectionWithEmptyParametersDoesNotAddInitializationC $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->never()) - ->method('addConnectCommand'); + $connection->expects($this->exactly(2)) + ->method('addConnectCommand') + ->withConsecutive( + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], + [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] + ); $factory = new Factory(); @@ -538,6 +558,27 @@ public function testDefineAndUndefineConnection(): void $factory->create('test://127.0.0.1'); } + /** + * @group disconnected + * @return void + */ + public function testSetClientNameAndVersionOnConnection(): void + { + $parameters = []; + + $factory = new Factory(); + $connection = $factory->create($parameters); + $initCommands = $connection->getInitCommands(); + + $this->assertInstanceOf(RawCommand::class, $initCommands[0]); + $this->assertSame('CLIENT', $initCommands[0]->getId()); + $this->assertSame(['SETINFO', 'LIB-NAME', 'predis'], $initCommands[0]->getArguments()); + + $this->assertInstanceOf(RawCommand::class, $initCommands[1]); + $this->assertSame('CLIENT', $initCommands[1]->getId()); + $this->assertSame(['SETINFO', 'LIB-VER', Client::VERSION], $initCommands[1]->getArguments()); + } + // ******************************************************************** // // ---- HELPER METHODS ------------------------------------------------ // // ******************************************************************** // diff --git a/tests/Predis/Connection/StreamConnectionTest.php b/tests/Predis/Connection/StreamConnectionTest.php index 55c30c082..cd38b4086 100644 --- a/tests/Predis/Connection/StreamConnectionTest.php +++ b/tests/Predis/Connection/StreamConnectionTest.php @@ -13,6 +13,7 @@ namespace Predis\Connection; use PHPUnit\Framework\MockObject\MockObject; +use Predis\Client; use Predis\Command\RawCommand; use Predis\Response\Error as ErrorResponse; @@ -195,4 +196,22 @@ public function testTcpDelayContextFlagIsNotSetByDefault() $this->assertArrayHasKey('tcp_nodelay', $options['socket']); $this->assertFalse($options['socket']['tcp_nodelay']); } + + /** + * @group connected + * @requiresRedisVersion < 7.0.0 + */ + public function testConnectDoNotThrowsExceptionOnClientCommandError(): void + { + $connection = $this->createConnectionWithParams([]); + $connection->addConnectCommand( + new RawCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis']) + ); + $connection->addConnectCommand( + new RawCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION]) + ); + + $connection->connect(); + $this->assertTrue(true); + } } From 1b2fd527ed9e4e55cca855996d933dbe84add9b9 Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Thu, 10 Aug 2023 18:57:00 +0300 Subject: [PATCH 04/23] Added support for Redis 7.0 arguments (#1359) --- src/ClientContextInterface.php | 1 + src/ClientInterface.php | 1 + src/Command/Redis/SHUTDOWN.php | 32 +++++++++++++++ tests/Predis/Command/Redis/SHUTDOWN_Test.php | 41 ++++++++++++++++++-- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php index 95f1590e7..d6b9bb90c 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -310,6 +310,7 @@ * @method $this evalsha($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null) * @method $this evalsha_ro(string $sha1, array $keys, ...$argument) * @method $this script($subcommand, $argument = null) + * @method $this shutdown(bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false) * @method $this auth($password) * @method $this echo($message) * @method $this ping($message = null) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 924db1ec5..5053c9dfc 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -328,6 +328,7 @@ * @method mixed evalsha(string $script, int $numkeys, string ...$keyOrArg = null) * @method mixed evalsha_ro(string $sha1, array $keys, ...$argument) * @method mixed script($subcommand, $argument = null) + * @method Status shutdown(bool $noSave = null, bool $now = false, bool $force = false, bool $abort = false) * @method mixed auth(string $password) * @method string echo(string $message) * @method mixed ping(string $message = null) diff --git a/src/Command/Redis/SHUTDOWN.php b/src/Command/Redis/SHUTDOWN.php index 7af576c6a..4d2b74794 100644 --- a/src/Command/Redis/SHUTDOWN.php +++ b/src/Command/Redis/SHUTDOWN.php @@ -26,4 +26,36 @@ public function getId() { return 'SHUTDOWN'; } + + /** + * {@inheritdoc} + */ + public function setArguments(array $arguments) + { + if (empty($arguments)) { + parent::setArguments($arguments); + + return; + } + + $processedArguments = []; + + if (array_key_exists(0, $arguments) && null !== $arguments[0]) { + $processedArguments[] = ($arguments[0]) ? 'SAVE' : 'NOSAVE'; + } + + if (array_key_exists(1, $arguments) && false !== $arguments[1]) { + $processedArguments[] = 'NOW'; + } + + if (array_key_exists(2, $arguments) && false !== $arguments[2]) { + $processedArguments[] = 'FORCE'; + } + + if (array_key_exists(3, $arguments) && false !== $arguments[3]) { + $processedArguments[] = 'ABORT'; + } + + parent::setArguments($processedArguments); + } } diff --git a/tests/Predis/Command/Redis/SHUTDOWN_Test.php b/tests/Predis/Command/Redis/SHUTDOWN_Test.php index ddf9f1122..533139db7 100644 --- a/tests/Predis/Command/Redis/SHUTDOWN_Test.php +++ b/tests/Predis/Command/Redis/SHUTDOWN_Test.php @@ -35,13 +35,48 @@ protected function getExpectedId(): string } /** + * @dataProvider argumentsProvider * @group disconnected */ - public function testFilterArguments(): void + public function testFilterArguments(array $actualArguments, array $expectedResponse): void { $command = $this->getCommand(); - $command->setArguments([]); + $command->setArguments($actualArguments); - $this->assertSame([], $command->getArguments()); + $this->assertSame($expectedResponse, $command->getArguments()); + } + + public function argumentsProvider(): array + { + return [ + 'with no arguments' => [ + [], + [], + ], + 'with SAVE argument' => [ + [true], + ['SAVE'], + ], + 'with NOSAVE argument' => [ + [false], + ['NOSAVE'], + ], + 'with NOW argument' => [ + [null, true], + ['NOW'], + ], + 'with FORCE argument' => [ + [null, false, true], + ['FORCE'], + ], + 'with ABORT argument' => [ + [null, false, false, true], + ['ABORT'], + ], + 'with all arguments' => [ + [true, true, true, true], + ['SAVE', 'NOW', 'FORCE', 'ABORT'], + ], + ]; } } From ffd31cfdefb5dfe63dc15040a716136432b9075d Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Thu, 10 Aug 2023 18:57:16 +0300 Subject: [PATCH 05/23] Added missing redis-stack commands to KeyPrefix processor (#1358) --- src/Command/Processor/KeyPrefixProcessor.php | 102 +++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php index 233ffa80a..05595ac11 100644 --- a/src/Command/Processor/KeyPrefixProcessor.php +++ b/src/Command/Processor/KeyPrefixProcessor.php @@ -189,6 +189,108 @@ public function __construct($prefix) /* ---------------- Redis 6.2 ---------------- */ 'GETDEL' => $prefixFirst, + + /* RedisJSON */ + 'JSON.ARRAPPEND' => $prefixFirst, + 'JSON.ARRINDEX' => $prefixFirst, + 'JSON.ARRINSERT' => $prefixFirst, + 'JSON.ARRLEN' => $prefixFirst, + 'JSON.ARRPOP' => $prefixFirst, + 'JSON.ARRTRIM' => $prefixFirst, + 'JSON.CLEAR' => $prefixFirst, + 'JSON.DEBUG MEMORY' => $prefixFirst, + 'JSON.DEL' => $prefixFirst, + 'JSON.FORGET' => $prefixFirst, + 'JSON.GET' => $prefixFirst, + 'JSON.MGET' => $prefixAll, + 'JSON.NUMINCRBY' => $prefixFirst, + 'JSON.OBJKEYS' => $prefixFirst, + 'JSON.OBJLEN' => $prefixFirst, + 'JSON.RESP' => $prefixFirst, + 'JSON.SET' => $prefixFirst, + 'JSON.STRAPPEND' => $prefixFirst, + 'JSON.STRLEN' => $prefixFirst, + 'JSON.TOGGLE' => $prefixFirst, + 'JSON.TYPE' => $prefixFirst, + + /* RedisBloom */ + 'BF.ADD' => $prefixFirst, + 'BF.EXISTS' => $prefixFirst, + 'BF.INFO' => $prefixFirst, + 'BF.INSERT' => $prefixFirst, + 'BF.LOADCHUNK' => $prefixFirst, + 'BF.MADD' => $prefixFirst, + 'BF.MEXISTS' => $prefixFirst, + 'BF.RESERVE' => $prefixFirst, + 'BF.SCANDUMP' => $prefixFirst, + 'CF.ADD' => $prefixFirst, + 'CF.ADDNX' => $prefixFirst, + 'CF.COUNT' => $prefixFirst, + 'CF.DEL' => $prefixFirst, + 'CF.EXISTS' => $prefixFirst, + 'CF.INFO' => $prefixFirst, + 'CF.INSERT' => $prefixFirst, + 'CF.INSERTNX' => $prefixFirst, + 'CF.LOADCHUNK' => $prefixFirst, + 'CF.MEXISTS' => $prefixFirst, + 'CF.RESERVE' => $prefixFirst, + 'CF.SCANDUMP' => $prefixFirst, + 'CMS.INCRBY' => $prefixFirst, + 'CMS.INFO' => $prefixFirst, + 'CMS.INITBYDIM' => $prefixFirst, + 'CMS.INITBYPROB' => $prefixFirst, + 'CMS.QUERY' => $prefixFirst, + 'TDIGEST.ADD' => $prefixFirst, + 'TDIGEST.BYRANK' => $prefixFirst, + 'TDIGEST.BYREVRANK' => $prefixFirst, + 'TDIGEST.CDF' => $prefixFirst, + 'TDIGEST.CREATE' => $prefixFirst, + 'TDIGEST.INFO' => $prefixFirst, + 'TDIGEST.MAX' => $prefixFirst, + 'TDIGEST.MIN' => $prefixFirst, + 'TDIGEST.QUANTILE' => $prefixFirst, + 'TDIGEST.RANK' => $prefixFirst, + 'TDIGEST.RESET' => $prefixFirst, + 'TDIGEST.REVRANK' => $prefixFirst, + 'TDIGEST.TRIMMED_MEAN' => $prefixFirst, + 'TOPK.ADD' => $prefixFirst, + 'TOPK.INCRBY' => $prefixFirst, + 'TOPK.INFO' => $prefixFirst, + 'TOPK.LIST' => $prefixFirst, + 'TOPK.QUERY' => $prefixFirst, + 'TOPK.RESERVE' => $prefixFirst, + + /* RediSearch */ + 'FT.AGGREGATE' => $prefixFirst, + 'FT.ALTER' => $prefixFirst, + 'FT.CREATE' => $prefixFirst, + 'FT.CURSOR DEL' => $prefixFirst, + 'FT.CURSOR READ' => $prefixFirst, + 'FT.DROPINDEX' => $prefixFirst, + 'FT.EXPLAIN' => $prefixFirst, + 'FT.INFO' => $prefixFirst, + 'FT.PROFILE' => $prefixFirst, + 'FT.SEARCH' => $prefixFirst, + 'FT.SPELLCHECK' => $prefixFirst, + 'FT.SYNDUMP' => $prefixFirst, + 'FT.SYNUPDATE' => $prefixFirst, + 'FT.TAGVALS' => $prefixFirst, + + /* Redis TimeSeries */ + 'TS.ADD' => $prefixFirst, + 'TS.ALTER' => $prefixFirst, + 'TS.CREATE' => $prefixFirst, + 'TS.DECRBY' => $prefixFirst, + 'TS.DEL' => $prefixFirst, + 'TS.GET' => $prefixFirst, + 'TS.INCRBY' => $prefixFirst, + 'TS.INFO' => $prefixFirst, + 'TS.MGET' => $prefixFirst, + 'TS.MRANGE' => $prefixFirst, + 'TS.MREVRANGE' => $prefixFirst, + 'TS.QUERYINDEX' => $prefixFirst, + 'TS.RANGE' => $prefixFirst, + 'TS.REVRANGE' => $prefixFirst, ]; } From 311cd2b79ec0d134294d723851075865b00d91d4 Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Mon, 14 Aug 2023 09:18:19 +0300 Subject: [PATCH 06/23] Added support for WAITAOF command (#1357) * Added support for WAITAOF command * Added call to parent setUp method --- examples/Commands/waitaof.php | 41 +++++++++++ src/ClientContextInterface.php | 1 + src/ClientInterface.php | 1 + src/Command/Redis/WAITAOF.php | 29 ++++++++ tests/Predis/Command/Redis/WAITAOF_Test.php | 80 +++++++++++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 examples/Commands/waitaof.php create mode 100644 src/Command/Redis/WAITAOF.php create mode 100644 tests/Predis/Command/Redis/WAITAOF_Test.php diff --git a/examples/Commands/waitaof.php b/examples/Commands/waitaof.php new file mode 100644 index 000000000..c9fd97059 --- /dev/null +++ b/examples/Commands/waitaof.php @@ -0,0 +1,41 @@ +info(); +$enabled = false; + +if ($info['Persistence']['aof_enabled'] === '0') { + $client->config('set', 'appendonly', 'yes'); + $enabled = true; +} + +// 2. Set key value pair +$response = $client->set('foo', 'bar'); +echo "Key-value pair set status: {$response}\n"; + +// 3. Run WAITAOF command to make sure that all previous writes was fsynced +$response = $client->waitaof(1, 0, 0); + +echo "Quantity of local instances that was fsynced - {$response[0]}, quantity of replicas - {$response[1]}"; + +// 4. Disable appendonly mode if it was enabled during script execution +if ($enabled) { + $client->config('set', 'appendonly', 'no'); +} diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php index d6b9bb90c..a92f4949b 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -304,6 +304,7 @@ * @method $this exec() * @method $this multi() * @method $this unwatch() + * @method $this waitaof(int $numLocal, int $numReplicas, int $timeout) * @method $this watch($key) * @method $this eval($script, $numkeys, $keyOrArg1 = null, $keyOrArgN = null) * @method $this eval_ro(string $script, array $keys, ...$argument) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 5053c9dfc..4f95400b1 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -322,6 +322,7 @@ * @method array|null exec() * @method mixed multi() * @method mixed unwatch() + * @method array waitaof(int $numLocal, int $numReplicas, int $timeout) * @method mixed watch(string $key) * @method mixed eval(string $script, int $numkeys, string ...$keyOrArg = null) * @method mixed eval_ro(string $script, array $keys, ...$argument) diff --git a/src/Command/Redis/WAITAOF.php b/src/Command/Redis/WAITAOF.php new file mode 100644 index 000000000..f58cc0547 --- /dev/null +++ b/src/Command/Redis/WAITAOF.php @@ -0,0 +1,29 @@ +getClient(); + $this->assertEquals('OK', $redis->config('set', 'appendonly', 'yes')); + } + + /** + * {@inheritDoc} + */ + protected function getExpectedCommand(): string + { + return WAITAOF::class; + } + + /** + * {@inheritDoc} + */ + protected function getExpectedId(): string + { + return 'WAITAOF'; + } + + /** + * @group disconnected + */ + public function testFilterArguments(): void + { + $actualArguments = $expectedArguments = [1, 2, 3]; + + $command = $this->getCommand(); + $command->setArguments($actualArguments); + + $this->assertSameValues($expectedArguments, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse(): void + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group connected + * @return void + * @requiresRedisVersion >= 7.2.0 + */ + public function testReturnQuantityOfSyncedAOFInstances(): void + { + $redis = $this->getClient(); + + $this->assertEquals('OK', $redis->set('foo', 'bar')); + $this->assertSame([1, 0], $redis->waitaof(1, 0, 0)); + } + + protected function tearDown(): void + { + $redis = $this->getClient(); + $this->assertEquals('OK', $redis->config('set', 'appendonly', 'no')); + } +} From f6cf2afe47eaec86beb9088e6c971d8f1646a86d Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Tue, 15 Aug 2023 18:43:46 +0300 Subject: [PATCH 07/23] Updated CHANGELOG.md (#1363) * Updated CHANGELOG.md * Added quotes to CHANGELOG.md * Codestyle fix --- CHANGELOG.md | 12 ++++++++++++ src/Connection/Replication/SentinelReplication.php | 1 + 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd565df74..1947380f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ ## Changelog +## v2.2.1 (2023-08-15) + +### Added +- Added support for new optional arguments: `PEXPIRE`, `PEXPIREAT`, `INFO`, `COMMAND` (Redis 6.2, 7) (#1330) +- Client set client name and version as a part of connection establishing process. (Redis 7.2) (#1347) +- Added support for `WAITAOF` command (#1357) +- Added missing redis-stack commands to `KeyPrefix processor` (#1358) +- Added support Redis 7.0 arguments for `SHUTDOWN command` (#1359) + +### Changed +- Changed interface of `CLIENT` command to more descriptive for each subcommand. (#1337) + ## v2.2.0 (2023-06-14) Predis v2.2.0 introduces official support for [Redis Stack](https://redis.io/docs/stack/) as well as a [Relay](https://github.com/cachewerk/relay) integration for substantially [faster read performance](https://github.com/predis/predis/wiki/Using-Relay). diff --git a/src/Connection/Replication/SentinelReplication.php b/src/Connection/Replication/SentinelReplication.php index 13fbedb17..14dbe2758 100644 --- a/src/Connection/Replication/SentinelReplication.php +++ b/src/Connection/Replication/SentinelReplication.php @@ -211,6 +211,7 @@ public function add(NodeConnectionInterface $connection) $this->master = $connection; } elseif ('sentinel' === $role) { $this->sentinels[] = $connection; + // sentinels are not considered part of the pool. return; } else { From 5f2b410a74afaff296a87a494e4c5488cf9fab57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Tue, 15 Aug 2023 16:01:46 -0700 Subject: [PATCH 08/23] Update CHANGELOG.md (#1364) * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1947380f6..484deb830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,14 +3,14 @@ ## v2.2.1 (2023-08-15) ### Added -- Added support for new optional arguments: `PEXPIRE`, `PEXPIREAT`, `INFO`, `COMMAND` (Redis 6.2, 7) (#1330) -- Client set client name and version as a part of connection establishing process. (Redis 7.2) (#1347) - Added support for `WAITAOF` command (#1357) -- Added missing redis-stack commands to `KeyPrefix processor` (#1358) -- Added support Redis 7.0 arguments for `SHUTDOWN command` (#1359) +- Added support for `SHUTDOWN` command (#1359) +- Added support for `FUNCTION` command (#1332) +- Added support for new optional `PEXPIRE`, `PEXPIREAT` and `COMMAND` +- Added missing Redis Stack commands to `KeyPrefixProcessor` (#1358) ### Changed -- Changed interface of `CLIENT` command to more descriptive for each subcommand. (#1337) +- Set client name and version when establishing a connection (#1347) ## v2.2.0 (2023-06-14) From c5ee202179dacd6b36f84186aac1fad752d29255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Tue, 15 Aug 2023 16:06:03 -0700 Subject: [PATCH 09/23] bump version (#1365) * bump version * Update Client.php --- VERSION | 2 +- src/Client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index c043eea77..84e6d845a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.1 +2.2.1-dev diff --git a/src/Client.php b/src/Client.php index 41bd1f3a3..911c0d773 100644 --- a/src/Client.php +++ b/src/Client.php @@ -53,7 +53,7 @@ */ class Client implements ClientInterface, IteratorAggregate { - public const VERSION = '2.2.1'; + public const VERSION = '2.2.1-dev'; /** @var OptionsInterface */ private $options; From 2d74db1bde1b21c8482ed181cfcf825bf05332ca Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Wed, 16 Aug 2023 18:18:45 +0300 Subject: [PATCH 10/23] Changes related to Redis 7.2 image update (#1366) * Added new assertion, fixed RESP3 JSON responses and versions * Removed expectations for error messages * Changed tests group for RESP3 not supported tests * Removed 3.x test case * Added missing test decorators * Fixed typo * Removed redisgraph module upload, as not a part of a redis-stack anymore --- docker/unstable_cluster/redis.conf | 1 - phpunit.relay.xml | 1 + .../AssertSameWithPrecisionConstraint.php | 81 +++++++++++++++++++ tests/PHPUnit/PredisTestCase.php | 15 ++++ .../Command/Redis/BloomFilter/BFADD_Test.php | 6 +- .../Redis/BloomFilter/BFEXISTS_Test.php | 3 +- .../Command/Redis/BloomFilter/BFINFO_Test.php | 4 +- .../Redis/BloomFilter/BFINSERT_Test.php | 3 + .../Redis/BloomFilter/BFLOADCHUNK_Test.php | 1 + .../Command/Redis/BloomFilter/BFMADD_Test.php | 6 +- .../Redis/BloomFilter/BFMEXISTS_Test.php | 3 +- .../Redis/BloomFilter/BFRESERVE_Test.php | 4 +- .../Redis/BloomFilter/BFSCANDUMP_Test.php | 1 + .../Redis/CountMinSketch/CMSINCRBY_Test.php | 1 + .../Redis/CountMinSketch/CMSINFO_Test.php | 1 + .../CountMinSketch/CMSINITBYDIM_Test.php | 1 + .../CountMinSketch/CMSINITBYPROB_Test.php | 1 + .../Redis/CountMinSketch/CMSMERGE_Test.php | 3 + .../Redis/CountMinSketch/CMSQUERY_Test.php | 1 + .../Redis/CuckooFilter/CFADDNX_Test.php | 1 + .../Command/Redis/CuckooFilter/CFADD_Test.php | 1 + .../Redis/CuckooFilter/CFCOUNT_Test.php | 1 + .../Command/Redis/CuckooFilter/CFDEL_Test.php | 1 + .../Redis/CuckooFilter/CFEXISTS_Test.php | 1 + .../Redis/CuckooFilter/CFINFO_Test.php | 1 + .../Redis/CuckooFilter/CFINSERTNX_Test.php | 3 + .../Redis/CuckooFilter/CFINSERT_Test.php | 4 + .../Redis/CuckooFilter/CFLOADCHUNK_Test.php | 1 + .../Redis/CuckooFilter/CFMEXISTS_Test.php | 3 +- .../Redis/CuckooFilter/CFRESERVE_Test.php | 1 + .../Redis/CuckooFilter/CFSCANDUMP_Test.php | 1 + .../Command/Redis/Json/JSONARRAPPEND_Test.php | 1 + .../Command/Redis/Json/JSONARRINDEX_Test.php | 1 + .../Command/Redis/Json/JSONARRINSERT_Test.php | 1 + .../Command/Redis/Json/JSONARRLEN_Test.php | 1 + .../Command/Redis/Json/JSONARRPOP_Test.php | 1 + .../Command/Redis/Json/JSONARRTRIM_Test.php | 1 + .../Command/Redis/Json/JSONCLEAR_Test.php | 1 + .../Command/Redis/Json/JSONDEBUG_Test.php | 1 + .../Command/Redis/Json/JSONDEL_Test.php | 1 + .../Command/Redis/Json/JSONFORGET_Test.php | 1 + .../Command/Redis/Json/JSONGET_Test.php | 2 + .../Command/Redis/Json/JSONMERGE_Test.php | 1 + .../Command/Redis/Json/JSONMGET_Test.php | 1 + .../Command/Redis/Json/JSONMSET_Test.php | 2 + .../Command/Redis/Json/JSONNUMINCRBY_Test.php | 1 + .../Command/Redis/Json/JSONOBJKEYS_Test.php | 1 + .../Command/Redis/Json/JSONOBJLEN_Test.php | 1 + .../Command/Redis/Json/JSONRESP_Test.php | 1 + .../Command/Redis/Json/JSONSET_Test.php | 1 + .../Command/Redis/Json/JSONSTRAPPEND_Test.php | 1 + .../Command/Redis/Json/JSONSTRLEN_Test.php | 1 + .../Command/Redis/Json/JSONTOGGLE_Test.php | 1 + .../Command/Redis/Json/JSONTYPE_Test.php | 1 + .../Command/Redis/Search/FTAGGREGATE_Test.php | 1 + .../Command/Redis/Search/FTALIASADD_Test.php | 2 + .../Command/Redis/Search/FTALIASDEL_Test.php | 1 + .../Redis/Search/FTALIASUPDATE_Test.php | 2 + .../Command/Redis/Search/FTALTER_Test.php | 1 + .../Command/Redis/Search/FTCONFIG_Test.php | 4 + .../Command/Redis/Search/FTCREATE_Test.php | 1 + .../Command/Redis/Search/FTCURSOR_Test.php | 3 + .../Command/Redis/Search/FTDICTADD_Test.php | 1 + .../Command/Redis/Search/FTDICTDEL_Test.php | 1 + .../Command/Redis/Search/FTDICTDUMP_Test.php | 1 + .../Command/Redis/Search/FTDROPINDEX_Test.php | 1 + .../Command/Redis/Search/FTEXPLAIN_Test.php | 1 + .../Command/Redis/Search/FTINFO_Test.php | 3 +- .../Command/Redis/Search/FTPROFILE_Test.php | 1 + .../Command/Redis/Search/FTSEARCH_Test.php | 6 +- .../Redis/Search/FTSPELLCHECK_Test.php | 1 + .../Command/Redis/Search/FTSUGADD_Test.php | 1 + .../Command/Redis/Search/FTSUGDEL_Test.php | 1 + .../Command/Redis/Search/FTSUGGET_Test.php | 2 + .../Command/Redis/Search/FTSUGLEN_Test.php | 1 + .../Command/Redis/Search/FTSYNDUMP_Test.php | 1 + .../Command/Redis/Search/FTSYNUPDATE_Test.php | 2 + .../Command/Redis/Search/FTTAGVALS_Test.php | 1 + .../Command/Redis/TDigest/TDIGESTADD_Test.php | 1 + .../Redis/TDigest/TDIGESTBYRANK_Test.php | 1 + .../Redis/TDigest/TDIGESTBYREVRANK_Test.php | 1 + .../Command/Redis/TDigest/TDIGESTCDF_Test.php | 5 +- .../Redis/TDigest/TDIGESTCREATE_Test.php | 1 + .../Redis/TDigest/TDIGESTINFO_Test.php | 1 + .../Command/Redis/TDigest/TDIGESTMAX_Test.php | 1 + .../Redis/TDigest/TDIGESTMERGE_Test.php | 5 ++ .../Command/Redis/TDigest/TDIGESTMIN_Test.php | 1 + .../Redis/TDigest/TDIGESTQUANTILE_Test.php | 1 + .../Redis/TDigest/TDIGESTRANK_Test.php | 1 + .../Redis/TDigest/TDIGESTRESET_Test.php | 1 + .../Redis/TDigest/TDIGESTREVRANK_Test.php | 1 + .../TDigest/TDIGESTTRIMMED_MEAN_Test.php | 2 + .../Command/Redis/TimeSeries/TSADD_Test.php | 1 + .../Command/Redis/TimeSeries/TSALTER_Test.php | 1 + .../Redis/TimeSeries/TSCREATERULE_Test.php | 2 + .../Redis/TimeSeries/TSCREATE_Test.php | 1 + .../Redis/TimeSeries/TSDECRBY_Test.php | 3 +- .../Redis/TimeSeries/TSDELETERULE_Test.php | 1 + .../Command/Redis/TimeSeries/TSDEL_Test.php | 1 + .../Command/Redis/TimeSeries/TSGET_Test.php | 1 + .../Redis/TimeSeries/TSINCRBY_Test.php | 3 +- .../Command/Redis/TimeSeries/TSINFO_Test.php | 1 + .../Command/Redis/TimeSeries/TSMADD_Test.php | 2 +- .../Command/Redis/TimeSeries/TSMGET_Test.php | 1 + .../Redis/TimeSeries/TSMRANGE_Test.php | 1 + .../Redis/TimeSeries/TSMREVRANGE_Test.php | 1 + .../Redis/TimeSeries/TSQUERYINDEX_Test.php | 1 + .../Command/Redis/TimeSeries/TSRANGE_Test.php | 1 + .../Redis/TimeSeries/TSREVRANGE_Test.php | 1 + .../Command/Redis/TopK/TOPKADD_Test.php | 1 + .../Command/Redis/TopK/TOPKINCRBY_Test.php | 1 + .../Command/Redis/TopK/TOPKINFO_Test.php | 6 +- .../Command/Redis/TopK/TOPKLIST_Test.php | 1 + .../Command/Redis/TopK/TOPKQUERY_Test.php | 1 + .../Command/Redis/TopK/TOPKRESERVE_Test.php | 3 +- tests/bootstrap.php | 1 + 116 files changed, 259 insertions(+), 22 deletions(-) create mode 100644 tests/PHPUnit/AssertSameWithPrecisionConstraint.php diff --git a/docker/unstable_cluster/redis.conf b/docker/unstable_cluster/redis.conf index 71928253e..a676f5776 100644 --- a/docker/unstable_cluster/redis.conf +++ b/docker/unstable_cluster/redis.conf @@ -3,7 +3,6 @@ # port, cluster-enabled, daemonize, logfile, dir protected-mode no loadmodule /opt/redis-stack/lib/redisearch.so -loadmodule /opt/redis-stack/lib/redisgraph.so loadmodule /opt/redis-stack/lib/redistimeseries.so loadmodule /opt/redis-stack/lib/rejson.so loadmodule /opt/redis-stack/lib/redisbloom.so diff --git a/phpunit.relay.xml b/phpunit.relay.xml index f8926a4fb..1b66a8936 100644 --- a/phpunit.relay.xml +++ b/phpunit.relay.xml @@ -20,6 +20,7 @@ relay-incompatible + relay-resp3 realm-webdis realm-stack ext-curl diff --git a/tests/PHPUnit/AssertSameWithPrecisionConstraint.php b/tests/PHPUnit/AssertSameWithPrecisionConstraint.php new file mode 100644 index 000000000..a96ea5c76 --- /dev/null +++ b/tests/PHPUnit/AssertSameWithPrecisionConstraint.php @@ -0,0 +1,81 @@ +expectedValue = $expectedValue; + $this->precision = $precision; + } + + /** + * {@inheritdoc} + */ + public function matches($other): bool + { + if (gettype($this->expectedValue) !== gettype($other)) { + return false; + } + + if (is_array($other)) { + $other = array_map([$this, 'roundToPrecision'], $other); + $this->expectedValue = array_map([$this, 'roundToPrecision'], $this->expectedValue); + + return !array_diff($this->expectedValue, $other); + } + + $other = $this->roundToPrecision($other); + $this->expectedValue = $this->roundToPrecision($this->expectedValue); + + return $other === $this->expectedValue; + } + + /** + * {@inheritDoc} + */ + public function toString(): string + { + return 'given value matches another value with given precision'; + } + + /** + * {@inheritdoc} + */ + protected function failureDescription($other): string + { + return $this->toString(); + } + + /** + * @param mixed $numeric + * @return float + */ + private function roundToPrecision($numeric): float + { + return round((float) $numeric, $this->precision); + } +} diff --git a/tests/PHPUnit/PredisTestCase.php b/tests/PHPUnit/PredisTestCase.php index 3dcdc1a4e..4ad148c15 100644 --- a/tests/PHPUnit/PredisTestCase.php +++ b/tests/PHPUnit/PredisTestCase.php @@ -10,6 +10,7 @@ * file that was distributed with this source code. */ +use PHPUnit\AssertSameWithPrecisionConstraint; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\OneOfConstraint; use PHPUnit\Util\Test as TestUtil; @@ -131,6 +132,20 @@ public function assertOneOf(array $expected, $actual, string $message = ''): voi $this->assertThat($actual, new OneOfConstraint($expected), $message); } + /** + * Asserts that two values (of the same type) have the same values with given precision. + * + * @param mixed $expected Expected value + * @param mixed $actual Actual value + * @param int $precision Precision value should be round to + * @param string $message Optional assertion message + * @return void + */ + public function assertSameWithPrecision($expected, $actual, int $precision = 0, string $message = ''): void + { + $this->assertThat($actual, new AssertSameWithPrecisionConstraint($expected, $precision), $message); + } + /** * Asserts that a string matches a given regular expression. * diff --git a/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php index 81bf9a909..81487c2fb 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFADD_Test.php @@ -61,8 +61,9 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void - * @requiresRedisBfVersion >= 1.0 + * @requiresRedisBfVersion >= 1.0.0 */ public function testAddGivenItemIntoBloomFilter(): void { @@ -75,7 +76,8 @@ public function testAddGivenItemIntoBloomFilter(): void /** * @group connected - * @requiresRedisBfVersion >= 1.0 + * @group relay-incompatible + * @requiresRedisBfVersion >= 1.0.0 */ public function testThrowsExceptionOnWrongType(): void { diff --git a/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php index 528453326..32e55fd53 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFEXISTS_Test.php @@ -60,8 +60,9 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void - * @requiresRedisBfVersion >= 1.0 + * @requiresRedisBfVersion >= 1.0.0 */ public function testExistsReturnsExistingItemWithinBloomFilter(): void { diff --git a/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php index e83e17cee..06f673790 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFINFO_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(array $actualResponse, array $expectedResponse /** * @group connected + * @group relay-resp3 * @dataProvider filtersProvider * @param array $filter * @param string $key @@ -98,7 +99,8 @@ public function testThrowsExceptionOnUnexpectedValueGiven(): void /** * @group connected - * @requiresRedisBfVersion >= 1.0 + * @group relay-resp3 + * @requiresRedisBfVersion >= 1.0.0 */ public function testThrowsExceptionOnWrongType(): void { diff --git a/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php index a53bcc89d..421174cdf 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFINSERT_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider filtersProvider * @param array $arguments * @param string $key @@ -101,6 +102,7 @@ public function testInsertThrowsExceptionOnNonExistingBloomFilterWithNoCreateMod /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ @@ -134,6 +136,7 @@ public function testInsertAddItemOnlyOnExistingFilterWithNoCreateModifier(): voi /** * @group connected + * @group relay-resp3 * @dataProvider unexpectedValuesProvider * @param array $arguments * @param string $expectedExceptionMessage diff --git a/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php index 4e443aa18..1c1133a96 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFLOADCHUNK_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php index 5b0b49685..da0def032 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFMADD_Test.php @@ -61,8 +61,9 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void - * @requiresRedisBfVersion >= 1.0 + * @requiresRedisBfVersion >= 1.0.0 */ public function testAddGivenItemsIntoBloomFilter(): void { @@ -75,7 +76,8 @@ public function testAddGivenItemsIntoBloomFilter(): void /** * @group connected - * @requiresRedisBfVersion >= 1.0 + * @group relay-incompatible + * @requiresRedisBfVersion >= 1.0.0 */ public function testThrowsExceptionOnWrongType(): void { diff --git a/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php index df151381a..d78cef77d 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFMEXISTS_Test.php @@ -60,8 +60,9 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void - * @requiresRedisBfVersion >= 1.0 + * @requiresRedisBfVersion >= 1.0.0 */ public function testExistsReturnsExistingItemsWithinBloomFilter(): void { diff --git a/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php index 1ac80529b..c5d8918fd 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFRESERVE_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider filtersProvider * @param array $filter * @param string $key @@ -98,7 +99,8 @@ public function testThrowsExceptionOnUnexpectedValueGiven(): void /** * @group connected - * @requiresRedisBfVersion >= 1.0 + * @group relay-resp3 + * @requiresRedisBfVersion >= 1.0.0 */ public function testThrowsExceptionOnWrongType(): void { diff --git a/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php b/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php index 78f4a9ec3..3d64db40c 100644 --- a/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php +++ b/tests/Predis/Command/Redis/BloomFilter/BFSCANDUMP_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php index d58779f1c..f41104bdf 100644 --- a/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php +++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINCRBY_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider sketchesProvider * @param array $incrementArguments * @param array $queryArguments diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php index 3f44471f7..0d343df1b 100644 --- a/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php +++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINFO_Test.php @@ -64,6 +64,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php index 4449ba629..35b901b9e 100644 --- a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php +++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYDIM_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php index f280456f3..28e4fac03 100644 --- a/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php +++ b/tests/Predis/Command/Redis/CountMinSketch/CMSINITBYPROB_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php index 42eb687ca..7b3d3f9d7 100644 --- a/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php +++ b/tests/Predis/Command/Redis/CountMinSketch/CMSMERGE_Test.php @@ -59,6 +59,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider sketchesProvider * @param array $mergeArguments * @param string $destinationKey @@ -107,6 +108,7 @@ public function testThrowsExceptionOnNonExistingDestinationCountMinSketch(): voi /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ @@ -125,6 +127,7 @@ public function testThrowsExceptionOnNonExistingSourceCountMinSketch(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ diff --git a/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php b/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php index f3335a615..bf7aa51fd 100644 --- a/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php +++ b/tests/Predis/Command/Redis/CountMinSketch/CMSQUERY_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider sketchesProvider * @param array $queryArguments * @param array $expectedResponse diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php index 94a6960b3..be99b8eab 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFADDNX_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php index 95f729905..cf720a3ab 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFADD_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php index 76306df79..1b86098fa 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFCOUNT_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php index 70f2c0985..8045b3e1b 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFDEL_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php index 78f6d0219..dceb09639 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFEXISTS_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php index 72ab27f20..f0f75f563 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFINFO_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(array $actualResponse, array $expectedResponse /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php index 1f8a1da49..7763fd9ac 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFINSERTNX_Test.php @@ -51,6 +51,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum /** * @group connected + * @group relay-resp3 * @dataProvider filtersProvider * @param array $filterArguments * @param string $key @@ -76,6 +77,7 @@ public function testInsertItemsIntoNonExistingCuckooFilter( /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ @@ -107,6 +109,7 @@ public function testInsertThrowsErrorOnInsertingIntoNonExistingFilterWithNoCreat /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php index 901040603..9c4bd79b5 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFINSERT_Test.php @@ -52,6 +52,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum /** * @group connected + * @group relay-resp3 * @dataProvider filtersProvider * @param array $filterArguments * @param string $key @@ -77,6 +78,7 @@ public function testInsertItemsIntoGivenCuckooFilter( /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ @@ -110,6 +112,7 @@ public function testInsertThrowsErrorOnInsertingIntoNonExistingFilterWithNoCreat /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ @@ -125,6 +128,7 @@ public function testInsertIntoAlreadyExistingFilterWithNoCreateModifier(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php index aaa738f95..0383c82bc 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFLOADCHUNK_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php index a1b91ca06..75c4fe227 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFMEXISTS_Test.php @@ -60,8 +60,9 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void - * @requiresRedisBfVersion >= 1.0 + * @requiresRedisBfVersion >= 1.0.0 */ public function testExistsReturnsExistingItemsWithinCuckooFilter(): void { diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php index eef7b0212..1b88687f9 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFRESERVE_Test.php @@ -51,6 +51,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum /** * @group connected + * @group relay-resp3 * @dataProvider filtersProvider * @param array $filterArguments * @param int $expectedCapacity diff --git a/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php b/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php index 1e6b5983a..cad364681 100644 --- a/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php +++ b/tests/Predis/Command/Redis/CuckooFilter/CFSCANDUMP_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php b/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php index 678463556..84a69a417 100644 --- a/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONARRAPPEND_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php b/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php index 43e91ca47..3a27c16cb 100644 --- a/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONARRINDEX_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php b/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php index 5bb2c758e..61298d3e2 100644 --- a/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONARRINSERT_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php b/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php index 6565e3471..e90255006 100644 --- a/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONARRLEN_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php b/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php index 6d80fd990..8bf1f37d5 100644 --- a/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONARRPOP_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php b/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php index a40de6a06..7ca362317 100644 --- a/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONARRTRIM_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php b/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php index 5e53cfa6f..4cffb5a1d 100644 --- a/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONCLEAR_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php b/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php index b13feec9d..0cde3a125 100644 --- a/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONDEBUG_Test.php @@ -56,6 +56,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONDEL_Test.php b/tests/Predis/Command/Redis/Json/JSONDEL_Test.php index 4d48d82f6..f8e2d0011 100644 --- a/tests/Predis/Command/Redis/Json/JSONDEL_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONDEL_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php b/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php index 9e5ef474a..0646b74d0 100644 --- a/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONFORGET_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONGET_Test.php b/tests/Predis/Command/Redis/Json/JSONGET_Test.php index 39c6cea8c..b1a278601 100644 --- a/tests/Predis/Command/Redis/Json/JSONGET_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONGET_Test.php @@ -59,6 +59,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonData * @param string $key @@ -101,6 +102,7 @@ public function testReturnsJsonValuesArrayOnMultiplePathsProvided(): void /** * @group connected + * @group relay-resp3 * @dataProvider unexpectedValuesProvider * @param array $arguments * @param string $expectedExceptionMessage diff --git a/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php b/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php index b9cb7a740..57ef01f45 100644 --- a/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONMERGE_Test.php @@ -57,6 +57,7 @@ public function testParseResponse(): void /** * @dataProvider jsonProvider * @group connected + * @group relay-resp3 * @param array $setArguments * @param array $mergeArguments * @param string $expectedResponse diff --git a/tests/Predis/Command/Redis/Json/JSONMGET_Test.php b/tests/Predis/Command/Redis/Json/JSONMGET_Test.php index 5700bfee4..19c703f29 100644 --- a/tests/Predis/Command/Redis/Json/JSONMGET_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONMGET_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $firstJson * @param array $secondJson diff --git a/tests/Predis/Command/Redis/Json/JSONMSET_Test.php b/tests/Predis/Command/Redis/Json/JSONMSET_Test.php index 2083d39c6..68fcbdb71 100644 --- a/tests/Predis/Command/Redis/Json/JSONMSET_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONMSET_Test.php @@ -57,6 +57,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisJsonVersion >= 2.6.0 */ @@ -70,6 +71,7 @@ public function testSetMultipleJsonDocuments(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisJsonVersion >= 2.6.0 */ diff --git a/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php b/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php index 3dc871894..918f382d8 100644 --- a/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONNUMINCRBY_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php b/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php index 5726e9a1a..706b1f7c4 100644 --- a/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONOBJKEYS_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php b/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php index 0380bc932..79f5ff5e5 100644 --- a/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONOBJLEN_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONRESP_Test.php b/tests/Predis/Command/Redis/Json/JSONRESP_Test.php index 5fa15aaf2..5df533542 100644 --- a/tests/Predis/Command/Redis/Json/JSONRESP_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONRESP_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONSET_Test.php b/tests/Predis/Command/Redis/Json/JSONSET_Test.php index dc1715f8c..3037058ac 100644 --- a/tests/Predis/Command/Redis/Json/JSONSET_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONSET_Test.php @@ -59,6 +59,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param string $key * @param string $defaultJson diff --git a/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php b/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php index 3f2b1e329..4cd19af43 100644 --- a/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONSTRAPPEND_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php b/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php index 4058d89a8..03fb285c9 100644 --- a/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONSTRLEN_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php b/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php index 40dc8950c..8d8aced44 100644 --- a/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONTOGGLE_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php b/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php index f40d4e13c..c90c76c65 100644 --- a/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php +++ b/tests/Predis/Command/Redis/Json/JSONTYPE_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider jsonProvider * @param array $jsonArguments * @param string $key diff --git a/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php b/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php index 5518709ec..943126517 100644 --- a/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php +++ b/tests/Predis/Command/Redis/Search/FTAGGREGATE_Test.php @@ -64,6 +64,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.1.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php b/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php index fb659acf4..cfdbbb608 100644 --- a/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php +++ b/tests/Predis/Command/Redis/Search/FTALIASADD_Test.php @@ -63,6 +63,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ @@ -100,6 +101,7 @@ public function testThrowsExceptionOnNonExistingIndex(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php b/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php index c448c7996..d5a599dbf 100644 --- a/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php +++ b/tests/Predis/Command/Redis/Search/FTALIASDEL_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php b/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php index e21531bb5..da383369e 100644 --- a/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php +++ b/tests/Predis/Command/Redis/Search/FTALIASUPDATE_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ @@ -99,6 +100,7 @@ public function testUpdateRemovesAliasAssociationFromAlreadyExistingAlias(): voi /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTALTER_Test.php b/tests/Predis/Command/Redis/Search/FTALTER_Test.php index 06e815e5f..146652695 100644 --- a/tests/Predis/Command/Redis/Search/FTALTER_Test.php +++ b/tests/Predis/Command/Redis/Search/FTALTER_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php b/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php index 8b75363e3..14a93dbee 100644 --- a/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php +++ b/tests/Predis/Command/Redis/Search/FTCONFIG_Test.php @@ -89,6 +89,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ @@ -101,6 +102,7 @@ public function testSetGivenRediSearchConfigurationParameter(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ @@ -114,6 +116,7 @@ public function testGetReturnsGivenRediSearchConfigurationParameter(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ @@ -136,6 +139,7 @@ public function testHelpReturnsGivenRediSearchConfigurationDescription(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTCREATE_Test.php b/tests/Predis/Command/Redis/Search/FTCREATE_Test.php index 746d3d7bc..d154b79c5 100644 --- a/tests/Predis/Command/Redis/Search/FTCREATE_Test.php +++ b/tests/Predis/Command/Redis/Search/FTCREATE_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php b/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php index a814eaacf..8044cb0d1 100644 --- a/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php +++ b/tests/Predis/Command/Redis/Search/FTCURSOR_Test.php @@ -79,6 +79,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.1.0 */ @@ -178,6 +179,7 @@ public function testDelExplicitlyRemovesExistingCursor(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.1.0 */ @@ -193,6 +195,7 @@ public function testReadThrowsExceptionOnWrongCursorId(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.1.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php b/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php index 577fda960..d4a4bfb16 100644 --- a/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php +++ b/tests/Predis/Command/Redis/Search/FTDICTADD_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.4.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php b/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php index 566add53f..465444652 100644 --- a/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php +++ b/tests/Predis/Command/Redis/Search/FTDICTDEL_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider dictionariesProvider * @param array $addArguments * @param array $deleteArguments diff --git a/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php b/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php index 7c260dc78..d95a6c40e 100644 --- a/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php +++ b/tests/Predis/Command/Redis/Search/FTDICTDUMP_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.4.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php b/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php index d026db7a7..d229f0513 100644 --- a/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php +++ b/tests/Predis/Command/Redis/Search/FTDROPINDEX_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 2.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php b/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php index 8d6dcead8..ac474ca63 100644 --- a/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php +++ b/tests/Predis/Command/Redis/Search/FTEXPLAIN_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTINFO_Test.php b/tests/Predis/Command/Redis/Search/FTINFO_Test.php index 6915e0066..98cc2170f 100644 --- a/tests/Predis/Command/Redis/Search/FTINFO_Test.php +++ b/tests/Predis/Command/Redis/Search/FTINFO_Test.php @@ -63,7 +63,7 @@ public function testParseResponse(): void /** * @group connected - * @group relay-incompatible + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 * @@ -96,7 +96,6 @@ public function testThrowsExceptionOnNonExistingIndex(): void $redis = $this->getClient(); $this->expectException(ServerException::class); - $this->expectExceptionMessage('Unknown Index name'); $redis->ftinfo('index'); } diff --git a/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php b/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php index 78c83c69c..694ab2aff 100644 --- a/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php +++ b/tests/Predis/Command/Redis/Search/FTPROFILE_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider queryProvider * @param array $createArguments * @param array $profileArguments diff --git a/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php b/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php index dfca91d5a..f7c690eba 100644 --- a/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php @@ -54,6 +54,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 * @requiresRedisJsonVersion >= 1.0.0 @@ -80,7 +81,7 @@ public function testSearchValuesByJsonIndex(): void $this->assertEquals('OK', $ftCreateResponse); // Timeout to make sure that index created before search performed. - usleep(2000); + usleep(10000); $ftSearchArguments = new SearchArguments(); $ftSearchArguments->addReturn(2, 'arr', 'val'); @@ -91,6 +92,7 @@ public function testSearchValuesByJsonIndex(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ @@ -114,7 +116,7 @@ public function testSearchValuesByHashIndex(): void $this->assertEquals('OK', $ftCreateResponse); // Timeout to make sure that index created before search performed. - usleep(2000); + usleep(10000); $ftSearchArguments = new SearchArguments(); $ftSearchArguments->addReturn(1, 'should_return'); diff --git a/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php b/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php index 16ee1f70a..55d91fcfc 100644 --- a/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSPELLCHECK_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.4.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php b/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php index f858796c9..5a0d3d055 100644 --- a/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSUGADD_Test.php @@ -59,6 +59,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php b/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php index 3a52e4204..edb5a02cf 100644 --- a/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSUGDEL_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php b/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php index 3239d53d0..90f83e857 100644 --- a/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSUGGET_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider suggestionProvider * @param array $addArguments * @param array $getArguments @@ -83,6 +84,7 @@ public function testGetSuggestionsForGivenPrefix( /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php b/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php index 214ed246b..b23a6aeca 100644 --- a/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSUGLEN_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php b/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php index 2821f65a7..f74d19921 100644 --- a/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSYNDUMP_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.2.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php b/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php index 21c5eb1b2..c015d79c9 100644 --- a/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSYNUPDATE_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.2.0 */ @@ -106,6 +107,7 @@ public function testUpdatesAlreadyExistingSynonymGroupWithinGivenIndex(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.2.0 */ diff --git a/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php b/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php index 80a7813a0..4bf809b31 100644 --- a/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php +++ b/tests/Predis/Command/Redis/Search/FTTAGVALS_Test.php @@ -63,6 +63,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRediSearchVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php index fa76ee6ac..896fa24f2 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTADD_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php index 4aadeb79d..8549c56a5 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTBYRANK_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php index 7fc8a3a19..232508f24 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTBYREVRANK_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php index 2b23e6aed..562150849 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTCDF_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ @@ -76,8 +77,8 @@ public function testReturnsValuesEstimatedForGivenRanks(): void $actualResponse = $redis->tdigestcdf('key', 0, 1, 2, 3, 4); - $this->assertEquals($expectedResponse, $actualResponse); - $this->assertEquals(['nan', 'nan'], $redis->tdigestcdf('empty_key', 0, 1)); + $this->assertSameWithPrecision($expectedResponse, $actualResponse, 5); + $this->assertSame(['nan', 'nan'], $redis->tdigestcdf('empty_key', 0, 1)); } /** diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php index 39bcc23c0..2ead7c260 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTCREATE_Test.php @@ -59,6 +59,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider sketchesProvider * @param array $createArguments * @param string $key diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php index 86072cc29..121b2d23f 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTINFO_Test.php @@ -77,6 +77,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php index 62b0a7a8e..9e9b7c20e 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTMAX_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php index b4d73071f..aa6cf45b1 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTMERGE_Test.php @@ -51,6 +51,7 @@ public function testFilterArguments(array $actualArguments, array $expectedArgum /** * @group connected + * @group relay-resp3 * @dataProvider sketchesProvider * @param string $sourceKey1 * @param string $sourceKey2 @@ -92,6 +93,7 @@ public function testMergeTwoSketchesIntoOneWithinGivenDestinationKey( /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ @@ -118,6 +120,7 @@ public function testMergedSketchHaveCompressionEqualMaxValueAmongAllSourceSketch /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ @@ -156,6 +159,7 @@ public function testMergeOverrideAlreadyExistingSketchWithOverrideModifier(): vo /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ @@ -184,6 +188,7 @@ public function testMergeWithAlreadyExistingSketchIfNoOverrideModifierGiven(): v /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php index c70629950..490508322 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTMIN_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php index b43cc5334..8a3622b3a 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTQUANTILE_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php index b3e2502f6..3afb63e1b 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTRANK_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php index bc3ebe25f..5ad1f76b9 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTRESET_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php index 67b4799d2..370fb1b6e 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTREVRANK_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php b/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php index 15490426b..001e07c92 100644 --- a/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php +++ b/tests/Predis/Command/Redis/TDigest/TDIGESTTRIMMED_MEAN_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider sketchesProvider * @param array $addArguments * @param string $key @@ -102,6 +103,7 @@ public function testReturnsNanOnEmptySketchKey(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.4.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php index a969e88e5..a59950499 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSADD_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php index 01f6fd3ee..9680448fc 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSALTER_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php index 25a448f25..5119a51e7 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSCREATERULE_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ @@ -95,6 +96,7 @@ public function testThrowsExceptionOnNonExistingDestinationKey(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php index ef7c66ceb..3e2183c45 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSCREATE_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php index b2d7e2107..1dbc91bdb 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSDECRBY_Test.php @@ -63,6 +63,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ @@ -121,6 +122,7 @@ public function testDecrByCreateNewSampleIfNotExists(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ @@ -147,7 +149,6 @@ public function testThrowsExceptionOnOlderTimestampGiven(): void ); $this->expectException(ServerException::class); - $this->expectExceptionMessage('TSDB: for incrby/decrby, timestamp should be newer than the'); $redis->tsdecrby('temperature:2:32', 27, (new DecrByArguments())->timestamp(123123123122)); } diff --git a/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php index ac5818943..eba727199 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSDELETERULE_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php index a9506eaba..744180595 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSDEL_Test.php @@ -63,6 +63,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.6.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php index 4ab298dff..d429dd884 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSGET_Test.php @@ -62,6 +62,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php index fbfceaca5..77ca7ff37 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSINCRBY_Test.php @@ -63,6 +63,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ @@ -121,6 +122,7 @@ public function testIncrByCreateNewSampleIfNotExists(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ @@ -147,7 +149,6 @@ public function testThrowsExceptionOnOlderTimestampGiven(): void ); $this->expectException(ServerException::class); - $this->expectExceptionMessage('TSDB: for incrby/decrby, timestamp should be newer than the'); $redis->tsincrby('temperature:2:32', 27, (new IncrByArguments())->timestamp(123123123122)); } diff --git a/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php index 20566d532..c796eebf1 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php index a9f8a11a7..860750ebe 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSMADD_Test.php @@ -63,6 +63,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ @@ -101,7 +102,6 @@ public function testThrowsExceptionOnNonWrongArgumentsNumber(): void $redis = $this->getClient(); $this->expectException(ServerException::class); - $this->expectExceptionMessage("ERR wrong number of arguments for 'TS.MADD' command"); $redis->tsmadd('temperature:2:32', 123123123123, 27, 'temperature:2:33', 123123123124); } diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php index 74d5b9810..50f18ca63 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSMGET_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php index cd7c126eb..cc13025a9 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSMRANGE_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php index 8d5a9adb9..5bfab8a9c 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSMREVRANGE_Test.php @@ -60,6 +60,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.4.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php index 0630300c8..0c75f93b5 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSQUERYINDEX_Test.php @@ -54,6 +54,7 @@ public function testFilterArguments(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php index b4c7b0df3..56caaa092 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSRANGE_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php b/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php index 1615f5c61..004615bcf 100644 --- a/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php +++ b/tests/Predis/Command/Redis/TimeSeries/TSREVRANGE_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisTimeSeriesVersion >= 1.0.0 */ diff --git a/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php b/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php index 19dd7e03e..ac568f6da 100644 --- a/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php +++ b/tests/Predis/Command/Redis/TopK/TOPKADD_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider structuresProvider * @param array $reserveArguments * @param array $addArguments diff --git a/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php b/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php index 06f605f28..bdd06c85e 100644 --- a/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php +++ b/tests/Predis/Command/Redis/TopK/TOPKINCRBY_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ diff --git a/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php b/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php index 2a0ca4c9b..6d7d2a055 100644 --- a/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php +++ b/tests/Predis/Command/Redis/TopK/TOPKINFO_Test.php @@ -64,6 +64,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ @@ -73,9 +74,10 @@ public function testReturnsInfoAboutGivenTopKStructure(): void $redis->topkreserve('key', 50); - $this->assertEquals( + $this->assertSameWithPrecision( ['k' => 50, 'width' => 8, 'depth' => 7, 'decay' => '0.90000000000000002'], - $redis->topkinfo('key') + $redis->topkinfo('key'), + 1 ); } diff --git a/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php b/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php index 795a0de3e..e20f5cade 100644 --- a/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php +++ b/tests/Predis/Command/Redis/TopK/TOPKLIST_Test.php @@ -63,6 +63,7 @@ public function testParseResponse(array $arguments, array $actualResponse, array /** * @group connected + * @group relay-resp3 * @dataProvider structureProvider * @param array $reserveArguments * @param array $addArguments diff --git a/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php b/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php index 721150e07..779775866 100644 --- a/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php +++ b/tests/Predis/Command/Redis/TopK/TOPKQUERY_Test.php @@ -61,6 +61,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @return void * @requiresRedisBfVersion >= 2.0.0 */ diff --git a/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php b/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php index 08a978ee4..a8261de1b 100644 --- a/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php +++ b/tests/Predis/Command/Redis/TopK/TOPKRESERVE_Test.php @@ -59,6 +59,7 @@ public function testParseResponse(): void /** * @group connected + * @group relay-resp3 * @dataProvider structureProvider * @param array $topKArguments * @param string $key @@ -77,7 +78,7 @@ public function testReserveInitializeTopKStructureWithGivenConfiguration( $actualInfoResponse = $redis->topkinfo($key); $this->assertEquals('OK', $actualResponse); - $this->assertEquals($expectedInfoResponse, $actualInfoResponse); + $this->assertSameWithPrecision($expectedInfoResponse, $actualInfoResponse, 1); } /** diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1e21c3579..be3b405ad 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -20,6 +20,7 @@ require __DIR__ . '/PHPUnit/ArrayHasSameValuesConstraint.php'; require __DIR__ . '/PHPUnit/OneOfConstraint.php'; +require __DIR__ . '/PHPUnit/AssertSameWithPrecisionConstraint.php'; require __DIR__ . '/PHPUnit/RedisCommandConstraint.php'; require __DIR__ . '/PHPUnit/PredisTestCase.php'; require __DIR__ . '/PHPUnit/PredisCommandTestCase.php'; From 912af82bfd05630a7fc2ccf014320e973c59f3b3 Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Thu, 17 Aug 2023 09:34:01 +0300 Subject: [PATCH 11/23] Added support for CLUSTER container command (#1360) * Added support for CLUSTER container command * Codestyle fixes --- src/ClientContextInterface.php | 2 + src/ClientInterface.php | 2 + src/Cluster/ClusterStrategy.php | 3 + src/Command/Redis/CLUSTER.php | 26 ++++ src/Command/Redis/Container/CLUSTER.php | 29 +++++ tests/Predis/Cluster/PredisStrategyTest.php | 3 + tests/Predis/Cluster/RedisStrategyTest.php | 3 + tests/Predis/Command/Redis/CLUSTER_Test.php | 117 ++++++++++++++++++ .../Command/Redis/Container/CLUSTER_Test.php | 27 ++++ 9 files changed, 212 insertions(+) create mode 100644 src/Command/Redis/CLUSTER.php create mode 100644 src/Command/Redis/Container/CLUSTER.php create mode 100644 tests/Predis/Command/Redis/CLUSTER_Test.php create mode 100644 tests/Predis/Command/Redis/Container/CLUSTER_Test.php diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php index a92f4949b..e443ee5d1 100644 --- a/src/ClientContextInterface.php +++ b/src/ClientContextInterface.php @@ -39,6 +39,7 @@ use Predis\Command\Argument\TimeSeries\RangeArguments; use Predis\Command\CommandInterface; use Predis\Command\Redis\Container\ACL; +use Predis\Command\Redis\Container\CLUSTER; use Predis\Command\Redis\Container\FunctionContainer; use Predis\Command\Redis\Container\Json\JSONDEBUG; use Predis\Command\Redis\Container\Search\FTCONFIG; @@ -340,6 +341,7 @@ * @method $this geosearchstore(string $destination, string $source, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $storeDist = false) * * Container commands + * @property CLUSTER $cluster * @property FunctionContainer $function * @property FTCONFIG $ftconfig * @property FTCURSOR $ftcursor diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 4f95400b1..2937c5804 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -40,6 +40,7 @@ use Predis\Command\CommandInterface; use Predis\Command\FactoryInterface; use Predis\Command\Redis\Container\ACL; +use Predis\Command\Redis\Container\CLUSTER; use Predis\Command\Redis\Container\FunctionContainer; use Predis\Command\Redis\Container\Json\JSONDEBUG; use Predis\Command\Redis\Container\Search\FTCONFIG; @@ -358,6 +359,7 @@ * @method int geosearchstore(string $destination, string $source, FromInterface $from, ByInterface $by, ?string $sorting = null, int $count = -1, bool $any = false, bool $storeDist = false) * * Container commands + * @property CLUSTER $cluster * @property FunctionContainer $function * @property FTCONFIG $ftconfig * @property FTCURSOR $ftcursor diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index 8b69ffdee..1965e26dd 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -174,6 +174,9 @@ protected function getDefaultCommands() 'GEODIST' => $getKeyFromFirstArgument, 'GEORADIUS' => [$this, 'getKeyFromGeoradiusCommands'], 'GEORADIUSBYMEMBER' => [$this, 'getKeyFromGeoradiusCommands'], + + /* cluster */ + 'CLUSTER' => [$this, 'getFakeKey'], ]; } diff --git a/src/Command/Redis/CLUSTER.php b/src/Command/Redis/CLUSTER.php new file mode 100644 index 000000000..3bbb77cc8 --- /dev/null +++ b/src/Command/Redis/CLUSTER.php @@ -0,0 +1,26 @@ + 'keys-first', 'GEORADIUS' => 'keys-georadius', 'GEORADIUSBYMEMBER' => 'keys-georadius', + + /* cluster */ + 'CLUSTER' => 'keys-fake', ]; if (isset($type)) { diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php index 2c31da119..d21b0b3bc 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -486,6 +486,9 @@ protected function getExpectedCommands(string $type = null): array 'GEODIST' => 'keys-first', 'GEORADIUS' => 'keys-georadius', 'GEORADIUSBYMEMBER' => 'keys-georadius', + + /* cluster */ + 'CLUSTER' => 'keys-fake', ]; if (isset($type)) { diff --git a/tests/Predis/Command/Redis/CLUSTER_Test.php b/tests/Predis/Command/Redis/CLUSTER_Test.php new file mode 100644 index 000000000..097f37167 --- /dev/null +++ b/tests/Predis/Command/Redis/CLUSTER_Test.php @@ -0,0 +1,117 @@ +getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsOfDelSlotsRange(): void + { + $arguments = ['DELSLOTSRANGE', 1, 1000]; + $expected = ['DELSLOTSRANGE', 1, 1000]; + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsOfLinks(): void + { + $arguments = ['LINKS']; + $expected = ['LINKS']; + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsOfShards(): void + { + $arguments = ['SHARDS']; + $expected = ['SHARDS']; + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group connected + * @group cluster + * @return void + * @requiresRedisVersion >= 7.0.0 + */ + public function testAddSlotsRangeToGivenNode(): void + { + $redis = $this->getClient(); + + [$startSlot, $endSlot] = $redis->cluster->shards()[0][1]; + + $this->assertEquals('OK', $redis->cluster->delSlotsRange($startSlot, $endSlot)); + $this->assertEquals('OK', $redis->cluster->addSlotsRange($startSlot, $endSlot)); + } + + /** + * @group connected + * @group cluster + * @return void + * @requiresRedisVersion >= 7.0.0 + */ + public function testLinksReturnsClusterPeerLinks(): void + { + $redis = $this->getClient(); + + $this->assertNotEmpty($redis->cluster->links()); + } +} diff --git a/tests/Predis/Command/Redis/Container/CLUSTER_Test.php b/tests/Predis/Command/Redis/Container/CLUSTER_Test.php new file mode 100644 index 000000000..c69d7e0cf --- /dev/null +++ b/tests/Predis/Command/Redis/Container/CLUSTER_Test.php @@ -0,0 +1,27 @@ +getMockBuilder(ClientInterface::class)->getMock(); + $command = new CLUSTER($mockClient); + + $this->assertSame('CLUSTER', $command->getContainerCommandId()); + } +} From 16bdd83d23b84a2182e129c63b1683a02c076556 Mon Sep 17 00:00:00 2001 From: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com> Date: Sat, 26 Aug 2023 00:27:24 +0300 Subject: [PATCH 12/23] Added EXPIRETIME command to KeyPrefixProcessor (#1369) * Added EXPIRETIME command to KeyPrefixProcessor * Fixed test responses for Redis 7.2 * Marked test as relay-incompatible --- src/Command/Processor/KeyPrefixProcessor.php | 3 +++ tests/Predis/ClientTest.php | 1 + .../Command/Processor/KeyPrefixProcessorTest.php | 5 +++++ tests/Predis/Command/Redis/ACL_Test.php | 2 +- tests/Predis/Command/Redis/OBJECT_Test.php | 15 ++++++++++++++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php index 05595ac11..d7a30c880 100644 --- a/src/Command/Processor/KeyPrefixProcessor.php +++ b/src/Command/Processor/KeyPrefixProcessor.php @@ -190,6 +190,9 @@ public function __construct($prefix) /* ---------------- Redis 6.2 ---------------- */ 'GETDEL' => $prefixFirst, + /* ---------------- Redis 7.0 ---------------- */ + 'EXPIRETIME' => $prefixFirst, + /* RedisJSON */ 'JSON.ARRAPPEND' => $prefixFirst, 'JSON.ARRINDEX' => $prefixFirst, diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index fba37d988..019058342 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -1255,6 +1255,7 @@ public function testGetIteratorWithNonTraversableConnectionNoException(): void /** * @group connected + * @group relay-incompatible * @requiresRedisVersion >= 7.2.0 */ public function testSetClientInfoOnConnection(): void diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php index b8acc4e1b..1cadb544d 100644 --- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -978,6 +978,11 @@ public function commandArgumentsDataProvider(): array ['key'], ['prefix:key'], ], + /* ---------------- Redis 7.0 ---------------- */ + ['EXPIRETIME', + ['key'], + ['prefix:key'], + ], ]; } } diff --git a/tests/Predis/Command/Redis/ACL_Test.php b/tests/Predis/Command/Redis/ACL_Test.php index ff3d5fc6f..3f270b5ed 100644 --- a/tests/Predis/Command/Redis/ACL_Test.php +++ b/tests/Predis/Command/Redis/ACL_Test.php @@ -101,7 +101,7 @@ public function testDryRunSimulateExecutionOfGivenCommandByUser(): void $redis->acl->dryRun('Test', 'SET', 'foo', 'bar') ); $this->assertEquals( - "This user has no permissions to run the 'get' command", + "User Test has no permissions to run the 'get' command", $redis->acl->dryRun('Test', 'GET', 'foo') ); } diff --git a/tests/Predis/Command/Redis/OBJECT_Test.php b/tests/Predis/Command/Redis/OBJECT_Test.php index 7fbec0e62..51e93ea53 100644 --- a/tests/Predis/Command/Redis/OBJECT_Test.php +++ b/tests/Predis/Command/Redis/OBJECT_Test.php @@ -82,7 +82,7 @@ public function testObjectIdletime(): void /** * @group connected - * @requiresRedisVersion >= 2.2.3 + * @requiresRedisVersion < 7.2.0 */ public function testObjectEncoding(): void { @@ -92,6 +92,19 @@ public function testObjectEncoding(): void $this->assertMatchesRegularExpression('/[zip|quick]list/', $redis->object('ENCODING', 'list:metavars')); } + /** + * @group connected + * @requiresRedisVersion >= 7.2.0 + */ + public function testObjectEncodingReturnsUpdatedResponse(): void + { + $redis = $this->getClient(); + + $redis->lpush('list:metavars', 'foo', 'bar'); + + $this->assertSame('listpack', $redis->object('ENCODING', 'list:metavars')); + } + /** * @group connected * @requiresRedisVersion >= 2.2.3 From a9be327ef39941fc323da9134ce96c5d98d836e0 Mon Sep 17 00:00:00 2001 From: mmodler Date: Thu, 20 Jul 2023 14:08:42 +0200 Subject: [PATCH 13/23] Update Prefix.php --- src/Configuration/Option/Prefix.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Configuration/Option/Prefix.php b/src/Configuration/Option/Prefix.php index 772454b36..a342cf177 100644 --- a/src/Configuration/Option/Prefix.php +++ b/src/Configuration/Option/Prefix.php @@ -12,6 +12,7 @@ namespace Predis\Configuration\Option; +use Closure; use Predis\Command\Processor\KeyPrefixProcessor; use Predis\Command\Processor\ProcessorInterface; use Predis\Configuration\OptionInterface; @@ -28,7 +29,7 @@ class Prefix implements OptionInterface */ public function filter(OptionsInterface $options, $value) { - if (is_callable($value)) { + if ($value instanceof Closure) { $value = call_user_func($value, $options); } From c6bf6448727ac15603ffe446d7bef19a2f3be371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Wed, 13 Sep 2023 09:34:52 -0700 Subject: [PATCH 14/23] bump dev version --- VERSION | 2 +- src/Client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 84e6d845a..97102b4a8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.1-dev +2.2.2-dev diff --git a/src/Client.php b/src/Client.php index 911c0d773..4b2b81245 100644 --- a/src/Client.php +++ b/src/Client.php @@ -53,7 +53,7 @@ */ class Client implements ClientInterface, IteratorAggregate { - public const VERSION = '2.2.1-dev'; + public const VERSION = '2.2.2-dev'; /** @var OptionsInterface */ private $options; From cbf394b8820d70367cf71c1fb8f34b802a726209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Wed, 13 Sep 2023 09:35:49 -0700 Subject: [PATCH 15/23] Disable `CLIENT SETINFO` calls by default (#1399) Add `client_info` parameter --- src/Connection/Factory.php | 2 +- src/Connection/ParametersInterface.php | 1 + tests/Predis/ClientTest.php | 17 ++++++++++- tests/Predis/Connection/FactoryTest.php | 38 +++++++------------------ 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/Connection/Factory.php b/src/Connection/Factory.php index c78c6d406..86b18c4a0 100644 --- a/src/Connection/Factory.php +++ b/src/Connection/Factory.php @@ -175,7 +175,7 @@ protected function prepareConnection(NodeConnectionInterface $connection) ); } - if (!$connection instanceof RelayConnection) { + if ($parameters->client_info ?? false && !$connection instanceof RelayConnection) { $connection->addConnectCommand( new RawCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis']) ); diff --git a/src/Connection/ParametersInterface.php b/src/Connection/ParametersInterface.php index 37ed97f7a..7893ea117 100644 --- a/src/Connection/ParametersInterface.php +++ b/src/Connection/ParametersInterface.php @@ -31,6 +31,7 @@ * @property string $database Database index (see the SELECT command). * @property bool $async_connect Performs the connect() operation asynchronously. * @property bool $tcp_nodelay Toggles the Nagle's algorithm for coalescing. + * @property bool $client_info Whether to set LIB-NAME and LIB-VER when connecting. * @property bool $cache (Relay only) Whether to use in-memory caching. * @property string $serializer (Relay only) Serializer used for data serialization. * @property string $compression (Relay only) Algorithm used for data compression. diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index 019058342..4489b2f04 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -1258,12 +1258,27 @@ public function testGetIteratorWithNonTraversableConnectionNoException(): void * @group relay-incompatible * @requiresRedisVersion >= 7.2.0 */ - public function testSetClientInfoOnConnection(): void + public function testDoNoSetClientInfoOnConnection(): void { $client = new Client($this->getParameters()); $libName = $client->client('LIST')[0]['lib-name']; $libVer = $client->client('LIST')[0]['lib-ver']; + $this->assertEmpty($libName); + $this->assertEmpty($libVer); + } + + /** + * @group connected + * @group relay-incompatible + * @requiresRedisVersion >= 7.2.0 + */ + public function testSetClientInfoOnConnectionWhenEnabled(): void + { + $client = new Client($this->getParameters(['client_info' => true])); + $libName = $client->client('LIST')[0]['lib-name']; + $libVer = $client->client('LIST')[0]['lib-ver']; + $this->assertSame('predis', $libName); $this->assertSame(Client::VERSION, $libVer); } diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php index 5e64497b7..9d48bd533 100644 --- a/tests/Predis/Connection/FactoryTest.php +++ b/tests/Predis/Connection/FactoryTest.php @@ -304,12 +304,10 @@ public function testCreateConnectionWithInitializationCommands(): void ->method('getParameters') ->willReturn($parameters); $connection - ->expects($this->exactly(4)) + ->expects($this->exactly(2)) ->method('addConnectCommand') ->withConsecutive( [$this->isRedisCommand('AUTH', ['foobar'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])], [$this->isRedisCommand('SELECT', ['0'])] ); @@ -335,13 +333,9 @@ public function testCreateConnectionWithPasswordAndNoUsernameAddsInitializationC $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->exactly(3)) + $connection->expects($this->once()) ->method('addConnectCommand') - ->withConsecutive( - [$this->isRedisCommand('AUTH', ['foobar'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] - ); + ->with($this->isRedisCommand('AUTH', ['foobar'])); $factory = new Factory(); @@ -366,13 +360,9 @@ public function testCreateConnectionWithPasswordAndUsernameAddsInitializationCom $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->exactly(3)) + $connection->expects($this->once()) ->method('addConnectCommand') - ->withConsecutive( - [$this->isRedisCommand('AUTH', ['myusername', 'foobar'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] - ); + ->with($this->isRedisCommand('AUTH', ['myusername', 'foobar'])); $factory = new Factory(); @@ -396,12 +386,8 @@ public function testCreateConnectionWithUsernameAndNoPasswordDoesNotAddInitializ $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->exactly(2)) - ->method('addConnectCommand') - ->withConsecutive( - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] - ); + $connection->expects($this->never()) + ->method('addConnectCommand'); $factory = new Factory(); @@ -426,12 +412,8 @@ public function testCreateConnectionWithEmptyParametersDoesNotAddInitializationC $connection->expects($this->once()) ->method('getParameters') ->will($this->returnValue($parameters)); - $connection->expects($this->exactly(2)) - ->method('addConnectCommand') - ->withConsecutive( - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-NAME', 'predis'])], - [$this->isRedisCommand('CLIENT', ['SETINFO', 'LIB-VER', Client::VERSION])] - ); + $connection->expects($this->never()) + ->method('addConnectCommand'); $factory = new Factory(); @@ -564,7 +546,7 @@ public function testDefineAndUndefineConnection(): void */ public function testSetClientNameAndVersionOnConnection(): void { - $parameters = []; + $parameters = ['client_info' => true]; $factory = new Factory(); $connection = $factory->create($parameters); From b1d3255ed9ad4d7254f9f9bba386c99f4bb983d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Wed, 13 Sep 2023 09:42:03 -0700 Subject: [PATCH 16/23] tag v2.2.2 --- CHANGELOG.md | 10 ++++++++++ VERSION | 2 +- src/Client.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 484deb830..61179b282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ ## Changelog +## v2.2.2 (2023-09-13) + +### Added +- Added `client_info` client parameter +- Added support for `CLUSTER` container command + +### Fixed +- Fixed `EXPIRETIME` not using `prefix` +- Disabled `CLIENT SETINFO` calls by default + ## v2.2.1 (2023-08-15) ### Added diff --git a/VERSION b/VERSION index 97102b4a8..b1b25a5ff 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.2-dev +2.2.2 diff --git a/src/Client.php b/src/Client.php index 4b2b81245..0b4511a52 100644 --- a/src/Client.php +++ b/src/Client.php @@ -53,7 +53,7 @@ */ class Client implements ClientInterface, IteratorAggregate { - public const VERSION = '2.2.2-dev'; + public const VERSION = '2.2.2'; /** @var OptionsInterface */ private $options; From d88153b63e3175accff006825ff0c48a1c1de8a8 Mon Sep 17 00:00:00 2001 From: Igor Malinovskiy Date: Wed, 13 Sep 2023 18:47:35 +0200 Subject: [PATCH 17/23] Add 7.2 to supported Redis versions (#1367) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d73754706..f435bab00 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ More details about this project can be found on the [frequently asked questions] ## Main features ## -- Support for Redis from __3.0__ to __7.0__. +- Support for Redis from __3.0__ to __7.2__. - Support for clustering using client-side sharding and pluggable keyspace distributors. - Support for [redis-cluster](http://redis.io/topics/cluster-tutorial) (Redis >= 3.0). - Support for master-slave replication setups and [redis-sentinel](http://redis.io/topics/sentinel). From 08d5298080c299038d2877956123a1909ec86674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Wed, 13 Sep 2023 09:49:11 -0700 Subject: [PATCH 18/23] fix typos --- FAQ.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FAQ.md b/FAQ.md index 65d34a0bd..098bda5de 100644 --- a/FAQ.md +++ b/FAQ.md @@ -33,7 +33,7 @@ but significantly reduces bytes sent over the network and Redis memory usage. Without Relay, Predis will not serialize data and will never do that by default. The reason behind this decision is that serialization is usually something that developers prefer to -customize depending on their needs and can not be easilygeneralized when using Redis because +customize depending on their needs and can not be easily generalized when using Redis because of the many possible access patterns for your data. This does not mean that it is impossible to have such a feature since you can leverage the extensibility of this library to define your own serialization-aware commands. You can find more details about how to do that @@ -90,7 +90,7 @@ Predis is fast enough when Redis is located on the same machine as PHP, more on [PhpRedis](https://github.com/phpredis/phpredis) (and Relay) perform significantly better when network I/O is involved, due to their ability to compress data by ~75%. Fewer bytes and received sent over the network [means faster operations](https://akalongman.medium.com/phpredis-vs-predis-comparison-on-real-production-data-a819b48cbadb), -and potentially cost savings when network traffic isn't free (e.g. AWS Elasticache Inter-AZ transfer costs). +and potentially cost savings when network traffic isn't free (e.g. AWS ElastiCache Inter-AZ transfer costs). ## Predis is a pure-PHP implementation: it can not be fast enough! ## From 92b284967e554b8f9513e0b9e902775fd82701ae Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 13 Sep 2023 19:50:19 +0300 Subject: [PATCH 19/23] Fix `cmsincrby` method annotation in `ClientInterface` (#1333) --- src/ClientInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 2937c5804..0aa7a38fe 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -109,7 +109,7 @@ * @method array cfinsertnx(string $key, int $capacity = -1, bool $noCreate = false, string ...$item) * @method Status cfreserve(string $key, int $capacity, int $bucketSize = -1, int $maxIterations = -1, int $expansion = -1) * @method array cfscandump(string $key, int $iterator) - * @method array cmsincrby(string $key, string|int...$itemIncrementDictionary) + * @method array cmsincrby(string $key, string|int ...$itemIncrementDictionary) * @method array cmsinfo(string $key) * @method Status cmsinitbydim(string $key, int $width, int $depth) * @method Status cmsinitbyprob(string $key, float $errorRate, float $probability) From 4846e2ab94697be8a1f786c6f7a68c19b88516b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Wed, 13 Sep 2023 09:55:14 -0700 Subject: [PATCH 20/23] back to dev version --- VERSION | 2 +- src/Client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index b1b25a5ff..7dd050c42 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.2 +2.2.3-dev diff --git a/src/Client.php b/src/Client.php index 0b4511a52..c73ff2e51 100644 --- a/src/Client.php +++ b/src/Client.php @@ -53,7 +53,7 @@ */ class Client implements ClientInterface, IteratorAggregate { - public const VERSION = '2.2.2'; + public const VERSION = '2.2.3-dev'; /** @var OptionsInterface */ private $options; From 6372661dbfba9bc1e4aba107e036af9ee2646776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Bok?= Date: Wed, 13 Sep 2023 18:59:50 +0200 Subject: [PATCH 21/23] Make Relay work with Redis cluster (#1397) --- .coveralls.yml | 1 + .gitattributes | 1 + .../workflows/cluster}/Dockerfile | 0 .../workflows/cluster}/create_cluster.sh | 0 .../workflows/cluster}/docker-compose.yml | 0 .../workflows/cluster}/redis.conf | 0 .github/workflows/linters.yml | 2 +- .github/workflows/tests.yml | 19 ++- src/Connection/Cluster/RedisCluster.php | 8 + src/Connection/RelayConnection.php | 23 ++- tests/Predis/Command/Redis/CLUSTER_Test.php | 15 +- tests/Predis/Command/Redis/GET_Test.php | 40 +++++ tests/Predis/Command/Redis/HGETALL_Test.php | 26 +++- tests/Predis/Command/Redis/HGET_Test.php | 26 +++- tests/Predis/Command/Redis/HSET_Test.php | 26 +++- tests/Predis/Command/Redis/SET_Test.php | 51 ++++++- .../Connection/Cluster/RedisClusterTest.php | 20 ++- .../Predis/Connection/RelayConnectionTest.php | 140 ++++++++++++++++++ 18 files changed, 379 insertions(+), 19 deletions(-) create mode 100644 .coveralls.yml rename {docker/unstable_cluster => .github/workflows/cluster}/Dockerfile (100%) rename {docker/unstable_cluster => .github/workflows/cluster}/create_cluster.sh (100%) rename {docker/unstable_cluster => .github/workflows/cluster}/docker-compose.yml (100%) rename {docker/unstable_cluster => .github/workflows/cluster}/redis.conf (100%) diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 000000000..c8f7bd3d5 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +coverage_clover: build/logs/clover-*.xml diff --git a/.gitattributes b/.gitattributes index 226cb6ab2..93cba263a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,7 @@ /examples export-ignore /tests export-ignore /.codespellrc export-ignore linguist-language=INI +/.coveralls.yml export-ignore /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore diff --git a/docker/unstable_cluster/Dockerfile b/.github/workflows/cluster/Dockerfile similarity index 100% rename from docker/unstable_cluster/Dockerfile rename to .github/workflows/cluster/Dockerfile diff --git a/docker/unstable_cluster/create_cluster.sh b/.github/workflows/cluster/create_cluster.sh similarity index 100% rename from docker/unstable_cluster/create_cluster.sh rename to .github/workflows/cluster/create_cluster.sh diff --git a/docker/unstable_cluster/docker-compose.yml b/.github/workflows/cluster/docker-compose.yml similarity index 100% rename from docker/unstable_cluster/docker-compose.yml rename to .github/workflows/cluster/docker-compose.yml diff --git a/docker/unstable_cluster/redis.conf b/.github/workflows/cluster/redis.conf similarity index 100% rename from docker/unstable_cluster/redis.conf rename to .github/workflows/cluster/redis.conf diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 1e22c8998..b6d481b08 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -136,7 +136,7 @@ jobs: EXPECTED="LICENSE,README.md,autoload.php,composer.json" CURRENT="$( git archive HEAD \ - | tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" --exclude="docker" --exclude="docker/*" \ + | tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" \ | paste --serial --delimiters="," )" echo "CURRENT =${CURRENT}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 44f3b7f3a..acc4fa4d4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -65,12 +65,16 @@ jobs: - name: Run tests with coverage if: ${{ matrix.php == '8.1' && matrix.redis == '7' }} - run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-filter ./src + run: vendor/bin/phpunit --coverage-clover build/logs/clover-default.xml --coverage-filter ./src - name: Run tests using Relay if: ${{ matrix.redis >= '6' }} run: vendor/bin/phpunit -c phpunit.relay.xml + - name: Run tests using Relay with coverage + if: ${{ matrix.php == '8.1' && matrix.redis == '7' }} + run: vendor/bin/phpunit -c phpunit.relay.xml --coverage-clover build/logs/clover-relay.xml --coverage-filter ./src + - name: Send coverage to Coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -99,12 +103,12 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Run redis cluster + - name: Run Redis cluster uses: isbang/compose-action@v1.4.1 with: - compose-file: "./docker/unstable_cluster/docker-compose.yml" + compose-file: .github/workflows/cluster/docker-compose.yml - - name: Setup PHP with Composer and extensions + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} @@ -119,5 +123,10 @@ jobs: - name: Run tests against cluster run: | - sleep 5 # Timeout to make sure that docker image is setup + sleep 5 # make sure that docker image is setup vendor/bin/phpunit --group cluster + + - name: Run tests against cluster using Relay + run: | + sleep 5 # make sure nodes are stable and fully joined + vendor/bin/phpunit -c phpunit.relay.xml --group cluster diff --git a/src/Connection/Cluster/RedisCluster.php b/src/Connection/Cluster/RedisCluster.php index 7f3013c17..ae2e18db9 100644 --- a/src/Connection/Cluster/RedisCluster.php +++ b/src/Connection/Cluster/RedisCluster.php @@ -464,6 +464,14 @@ protected function onMovedResponse(CommandInterface $command, $details) { [$slot, $connectionID] = explode(' ', $details, 2); + // Handle connection ID in the form of "IP:port (details about exception)" + // by trimming everything after first space (including the space) + $startPositionOfExtraDetails = strpos($connectionID, ' '); + + if ($startPositionOfExtraDetails !== false) { + $connectionID = substr($connectionID, 0, $startPositionOfExtraDetails); + } + if (!$connection = $this->getConnectionById($connectionID)) { $connection = $this->createConnection($connectionID); } diff --git a/src/Connection/RelayConnection.php b/src/Connection/RelayConnection.php index 4ff674f5f..aa78e313f 100644 --- a/src/Connection/RelayConnection.php +++ b/src/Connection/RelayConnection.php @@ -16,6 +16,7 @@ use Predis\ClientException; use Predis\Command\CommandInterface; use Predis\NotSupportedException; +use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ServerException; use Relay\Exception as RelayException; use Relay\Relay; @@ -198,9 +199,13 @@ public function getClient() /** * {@inheritdoc} */ - protected function getIdentifier() + public function getIdentifier() { - return $this->client->endpointId(); + try { + return $this->client->endpointId(); + } catch (RelayException $ex) { + return parent::getIdentifier(); + } } /** @@ -253,7 +258,13 @@ public function executeCommand(CommandInterface $command) ? $this->client->{$name}(...$command->getArguments()) : $this->client->rawCommand($name, ...$command->getArguments()); } catch (RelayException $ex) { - throw $this->onCommandError($ex, $command); + $exception = $this->onCommandError($ex, $command); + + if ($exception instanceof ErrorResponseInterface) { + return $exception; + } + + throw $exception; } } @@ -265,15 +276,15 @@ public function onCommandError(RelayException $exception, CommandInterface $comm $code = $exception->getCode(); $message = $exception->getMessage(); - if (strpos($message, 'RELAY_ERR_IO')) { + if (strpos($message, 'RELAY_ERR_IO') !== false) { return new ConnectionException($this, $message, $code, $exception); } - if (strpos($message, 'RELAY_ERR_REDIS')) { + if (strpos($message, 'RELAY_ERR_REDIS') !== false) { return new ServerException($message, $code, $exception); } - if (strpos($message, 'RELAY_ERR_WRONGTYPE') && strpos($message, "Got reply-type 'status'")) { + if (strpos($message, 'RELAY_ERR_WRONGTYPE') !== false && strpos($message, "Got reply-type 'status'") !== false) { $message = 'Operation against a key holding the wrong kind of value'; } diff --git a/tests/Predis/Command/Redis/CLUSTER_Test.php b/tests/Predis/Command/Redis/CLUSTER_Test.php index 097f37167..f693db750 100644 --- a/tests/Predis/Command/Redis/CLUSTER_Test.php +++ b/tests/Predis/Command/Redis/CLUSTER_Test.php @@ -96,7 +96,20 @@ public function testAddSlotsRangeToGivenNode(): void { $redis = $this->getClient(); - [$startSlot, $endSlot] = $redis->cluster->shards()[0][1]; + // Sometimes the cluster can be in a state where slots are + // missing on some shards (e.g. they are being rebalanced) + $shards = $redis->cluster->shards(); + $slots = $shards[0][1] ?? $shards[0]['slots']; + + if (empty($slots)) { + $slots = $shards[1][1] ?? $shards[1]['slots']; + } + + if (empty($slots)) { + $slots = $shards[2][1] ?? $shards[2]['slots']; + } + + [$startSlot, $endSlot] = $slots; $this->assertEquals('OK', $redis->cluster->delSlotsRange($startSlot, $endSlot)); $this->assertEquals('OK', $redis->cluster->addSlotsRange($startSlot, $endSlot)); diff --git a/tests/Predis/Command/Redis/GET_Test.php b/tests/Predis/Command/Redis/GET_Test.php index 80c047b7a..3409ae349 100644 --- a/tests/Predis/Command/Redis/GET_Test.php +++ b/tests/Predis/Command/Redis/GET_Test.php @@ -67,6 +67,16 @@ public function testReturnsStringValue(): void $this->assertEquals('bar', $redis->get('foo')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testReturnsStringValueUsingCluster(): void + { + $this->testReturnsStringValue(); + } + /** * @group connected */ @@ -80,6 +90,16 @@ public function testReturnsEmptyStringOnEmptyStrings(): void $this->assertSame('', $redis->get('foo')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testReturnsEmptyStringOnEmptyStringsUsingCluster(): void + { + $this->testReturnsEmptyStringOnEmptyStrings(); + } + /** * @group connected */ @@ -91,6 +111,16 @@ public function testReturnsNullOnNonExistingKeys(): void $this->assertNull($redis->get('foo')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testReturnsNullOnNonExistingKeysUsingCluster(): void + { + $this->testReturnsNullOnNonExistingKeys(); + } + /** * @group connected */ @@ -104,4 +134,14 @@ public function testThrowsExceptionOnWrongType(): void $redis->rpush('metavars', 'foo'); $redis->get('metavars'); } + + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testThrowsExceptionOnWrongTypeUsingCluster(): void + { + $this->testThrowsExceptionOnWrongType(); + } } diff --git a/tests/Predis/Command/Redis/HGETALL_Test.php b/tests/Predis/Command/Redis/HGETALL_Test.php index 308a3f580..41e799f3a 100644 --- a/tests/Predis/Command/Redis/HGETALL_Test.php +++ b/tests/Predis/Command/Redis/HGETALL_Test.php @@ -75,6 +75,20 @@ public function testReturnsAllTheFieldsAndTheirValues(): void $this->assertSame([], $redis->hgetall('unknown')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testReturnsAllTheFieldsAndTheirValuesUsingCluster(): void + { + $redis = $this->getClient(); + + $redis->del('metavars'); + + $this->testReturnsAllTheFieldsAndTheirValues(); + } + /** * @group connected * @requiresRedisVersion >= 2.0.0 @@ -82,11 +96,21 @@ public function testReturnsAllTheFieldsAndTheirValues(): void public function testThrowsExceptionOnWrongType(): void { $this->expectException('Predis\Response\ServerException'); - $this->expectExceptionMessage('Operation against a key holding the wrong kind of value'); + $this->expectExceptionMessageMatches('/.*Operation against a key holding the wrong kind of value.*/'); $redis = $this->getClient(); $redis->set('foo', 'bar'); $redis->hgetall('foo'); } + + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testThrowsExceptionOnWrongTypeUsingCluster(): void + { + $this->testThrowsExceptionOnWrongType(); + } } diff --git a/tests/Predis/Command/Redis/HGET_Test.php b/tests/Predis/Command/Redis/HGET_Test.php index 443cb4e8b..3efe2a356 100644 --- a/tests/Predis/Command/Redis/HGET_Test.php +++ b/tests/Predis/Command/Redis/HGET_Test.php @@ -71,6 +71,20 @@ public function testReturnsValueOfSpecifiedField(): void $this->assertNull($redis->hget('unknown', 'foo')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testReturnsValueOfSpecifiedFieldUsingCluster(): void + { + $redis = $this->getClient(); + + $redis->del('metavars'); + + $this->testReturnsValueOfSpecifiedField(); + } + /** * @group connected * @requiresRedisVersion >= 2.0.0 @@ -78,11 +92,21 @@ public function testReturnsValueOfSpecifiedField(): void public function testThrowsExceptionOnWrongType(): void { $this->expectException('Predis\Response\ServerException'); - $this->expectExceptionMessage('Operation against a key holding the wrong kind of value'); + $this->expectExceptionMessageMatches('/.*Operation against a key holding the wrong kind of value.*/'); $redis = $this->getClient(); $redis->set('foo', 'bar'); $redis->hget('foo', 'bar'); } + + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testThrowsExceptionOnWrongTypeUsingCluster(): void + { + $this->testThrowsExceptionOnWrongType(); + } } diff --git a/tests/Predis/Command/Redis/HSET_Test.php b/tests/Predis/Command/Redis/HSET_Test.php index e6d77ae2f..6cd60918a 100644 --- a/tests/Predis/Command/Redis/HSET_Test.php +++ b/tests/Predis/Command/Redis/HSET_Test.php @@ -73,6 +73,20 @@ public function testSetsValueOfSpecifiedField(): void $this->assertSame(['bar', 'piyo'], $redis->hmget('metavars', 'foo', 'hoge')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testSetsValueOfSpecifiedFieldUsingCluster(): void + { + $redis = $this->getClient(); + + $redis->del('metavars'); + + $this->testSetsValueOfSpecifiedField(); + } + /** * @group connected * @requiresRedisVersion >= 2.0.0 @@ -80,11 +94,21 @@ public function testSetsValueOfSpecifiedField(): void public function testThrowsExceptionOnWrongType(): void { $this->expectException('Predis\Response\ServerException'); - $this->expectExceptionMessage('Operation against a key holding the wrong kind of value'); + $this->expectExceptionMessageMatches('/.*Operation against a key holding the wrong kind of value.*/'); $redis = $this->getClient(); $redis->set('metavars', 'foo'); $redis->hset('metavars', 'foo', 'bar'); } + + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testThrowsExceptionOnWrongTypeUsingCluster(): void + { + $this->testThrowsExceptionOnWrongType(); + } } diff --git a/tests/Predis/Command/Redis/SET_Test.php b/tests/Predis/Command/Redis/SET_Test.php index 107ac9adb..71f4aaf2f 100644 --- a/tests/Predis/Command/Redis/SET_Test.php +++ b/tests/Predis/Command/Redis/SET_Test.php @@ -82,6 +82,16 @@ public function testSetStringValue(): void $this->assertSame('bar', $redis->get('foo')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testSetStringValueUsingCluster(): void + { + $this->testSetStringValue(); + } + /** * @group connected * @requiresRedisVersion >= 2.6.12 @@ -94,6 +104,16 @@ public function testSetStringValueWithModifierEX(): void $this->assertSame(1, $redis->ttl('foo')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testSetStringValueWithModifierEXUsingCluster(): void + { + $this->testSetStringValueWithModifierEX(); + } + /** * @group connected * @requiresRedisVersion >= 2.6.12 @@ -109,6 +129,16 @@ public function testSetStringValueWithModifierPX(): void $this->assertLessThanOrEqual(1000, $pttl); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testSetStringValueWithModifierPXUsingCluster(): void + { + $this->testSetStringValueWithModifierPX(); + } + /** * @group connected * @requiresRedisVersion >= 2.6.12 @@ -121,6 +151,16 @@ public function testSetStringValueWithModifierNX(): void $this->assertNull($redis->set('foo', 'bar', 'NX')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testSetStringValueWithModifierNXUsingCluster(): void + { + $this->testSetStringValueWithModifierNX(); + } + /** * @group connected * @requiresRedisVersion >= 2.6.12 @@ -135,11 +175,20 @@ public function testSetStringValueWithModifierXX(): void $this->assertNull($redis->set('foofoo', 'barbar', 'XX')); } + /** + * @group connected + * @group cluster + * @requiresRedisVersion >= 6.0.0 + */ + public function testSetStringValueWithModifierXXUsingCluster(): void + { + $this->testSetStringValueWithModifierXX(); + } + /** * @group connected * @group cluster * @requiresRedisVersion >= 3.0.0 - * @return void */ public function testSetStringValueInClusterMode(): void { diff --git a/tests/Predis/Connection/Cluster/RedisClusterTest.php b/tests/Predis/Connection/Cluster/RedisClusterTest.php index cf021b2cc..7388bed3c 100644 --- a/tests/Predis/Connection/Cluster/RedisClusterTest.php +++ b/tests/Predis/Connection/Cluster/RedisClusterTest.php @@ -12,6 +12,7 @@ namespace Predis\Connection\Cluster; +use Iterator; use PHPUnit\Framework\MockObject\MockObject; use Predis\Cluster; use Predis\Command; @@ -1212,11 +1213,12 @@ public function testFetchSlotsMapFromClusterWithClusterSlotsCommand(): void /** * @group disconnected + * @dataProvider onMovedResponsesDataProvider */ - public function testAskSlotMapToRedisClusterOnMovedResponseByDefault(): void + public function testAskSlotMapToRedisClusterOnMovedResponseByDefault(string $movedErrorMessage): void { $cmdGET = Command\RawCommand::create('GET', 'node:1001'); - $rspMOVED = new Response\Error('MOVED 1970 127.0.0.1:6380'); + $rspMOVED = new Response\Error($movedErrorMessage); $rspSlotsArray = [ [0, 8191, ['127.0.0.1', 6379]], [8192, 16383, ['127.0.0.1', 6380]], @@ -1261,6 +1263,20 @@ public function testAskSlotMapToRedisClusterOnMovedResponseByDefault(): void $this->assertCount(2, $cluster); } + /** + * @return Iterator + */ + public function onMovedResponsesDataProvider(): Iterator + { + yield 'MOVED 1970 127.0.0.1:6380' => [ + 'movedErrorMessage' => 'MOVED 1970 127.0.0.1:6380', + ]; + + yield 'MOVED 1970 127.0.0.1:6380 (relay exception details)' => [ + 'movedErrorMessage' => 'MOVED 1970 127.0.0.1:6380 (relay exception details)', + ]; + } + /** * @group disconnected */ diff --git a/tests/Predis/Connection/RelayConnectionTest.php b/tests/Predis/Connection/RelayConnectionTest.php index 11bc72e33..895fb78ea 100644 --- a/tests/Predis/Connection/RelayConnectionTest.php +++ b/tests/Predis/Connection/RelayConnectionTest.php @@ -13,8 +13,13 @@ namespace Predis\Connection; use PHPUnit\Framework\MockObject\MockObject; +use Predis\ClientException; use Predis\Command\RawCommand; use Predis\Response\Error as ErrorResponse; +use Predis\Response\ErrorInterface as ErrorResponseInterface; +use ReflectionClass; +use Relay\Exception as RelayException; +use Relay\Relay; /** * @group ext-relay @@ -59,6 +64,141 @@ public function testThrowsExceptionOnInitializationCommandFailure(): void $connection->connect(); } + /** + * @group connected + */ + public function testGetIdentifierUsesParentGetIdentifier(): void + { + $relayMock = $this + ->getMockBuilder(Relay::class) + ->onlyMethods(['endpointId']) + ->getMock(); + + $relayMock->method('endpointId') + ->willThrowException( + new RelayException('Not Connected') + ); + + /** @var RelayConnection&MockObject $connection */ + $connection = $this + ->getMockBuilder($this->getConnectionClass()) + ->onlyMethods(['createResource']) + ->disableOriginalConstructor() + ->getMock(); + + $reflection = new ReflectionClass($connection); + $propertyClient = $reflection->getProperty('client'); + $propertyClient->setAccessible(true); + $propertyClient->setValue($connection, $relayMock); + $propertyParameters = $reflection->getProperty('parameters'); + $propertyParameters->setAccessible(true); + $propertyParameters->setValue($connection, new Parameters([ + 'host' => '127.0.0.1', + 'port' => 6379, + ])); + + $this->assertEquals('127.0.0.1:6379', $connection->getIdentifier()); + } + + /** + * @group connected + */ + public function testGetIdentifierUsesClientEndpointId(): void + { + $relayMock = $this + ->getMockBuilder(Relay::class) + ->onlyMethods(['endpointId']) + ->getMock(); + + $relayMock->method('endpointId') + ->willReturn('127.0.0.1:6379'); + + /** @var RelayConnection&MockObject $connection */ + $connection = $this + ->getMockBuilder($this->getConnectionClass()) + ->onlyMethods(['createResource']) + ->disableOriginalConstructor() + ->getMock(); + + $reflection = new ReflectionClass($connection); + $propertyClient = $reflection->getProperty('client'); + $propertyClient->setAccessible(true); + $propertyClient->setValue($connection, $relayMock); + + $this->assertEquals('127.0.0.1:6379', $connection->getIdentifier()); + } + + /** + * @group connected + */ + public function testExecuteCommandReturnsErrorResponseWhenItIsThrownByRelay(): void + { + $cmdSelect = RawCommand::create('GET', '1'); + + $relayMock = $this + ->getMockBuilder(Relay::class) + ->onlyMethods(['rawCommand']) + ->getMock(); + + $relayMock->method('rawCommand') + ->willThrowException( + new RelayException('RELAY_ERR_REDIS') + ); + + /** @var RelayConnection&MockObject $connection */ + $connection = $this + ->getMockBuilder($this->getConnectionClass()) + ->onlyMethods(['createResource', 'createClient']) + ->disableOriginalConstructor() + ->getMock(); + + $reflection = new ReflectionClass($connection); + $property = $reflection->getProperty('client'); + $property->setAccessible(true); + $property->setValue($connection, $relayMock); + + $connection->method('createResource'); + + $response = $connection->executeCommand($cmdSelect); + + $this->assertInstanceOf(ErrorResponseInterface::class, $response); + } + + /** + * @group connected + */ + public function testExecuteCommandThrowsExceptionWhenThrownByRelayAndItIsNotErrorResponse(): void + { + $this->expectException('Predis\ClientException'); + $cmdSelect = RawCommand::create('GET', '1'); + + $relayMock = $this + ->getMockBuilder(Relay::class) + ->onlyMethods(['rawCommand']) + ->getMock(); + + $relayMock->method('rawCommand') + ->willThrowException( + new ClientException('RELAY_ERR_REDIS') + ); + + /** @var RelayConnection&MockObject $connection */ + $connection = $this + ->getMockBuilder($this->getConnectionClass()) + ->onlyMethods(['createResource', 'createClient']) + ->disableOriginalConstructor() + ->getMock(); + + $reflection = new ReflectionClass($connection); + $property = $reflection->getProperty('client'); + $property->setAccessible(true); + $property->setValue($connection, $relayMock); + + $connection->method('createResource'); + + $connection->executeCommand($cmdSelect); + } + // ******************************************************************** // // ---- INTEGRATION TESTS --------------------------------------------- // // ******************************************************************** // From 577bd398727a6fc953658563b1271e498f059098 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 14 Sep 2023 17:44:52 +0100 Subject: [PATCH 22/23] ClientInterface: using set with NX flag can return null (#1394) Calling `$client->set('key', '1', 'EX', 7200, 'NX')` for a key that is already set will return null instead of Status --- src/ClientInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 0aa7a38fe..5250dabd5 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -155,7 +155,7 @@ * @method mixed mset(array $dictionary) * @method int msetnx(array $dictionary) * @method Status psetex(string $key, $milliseconds, $value) - * @method Status set(string $key, $value, $expireResolution = null, $expireTTL = null, $flag = null) + * @method Status|null set(string $key, $value, $expireResolution = null, $expireTTL = null, $flag = null) * @method int setbit(string $key, $offset, $value) * @method Status setex(string $key, $seconds, $value) * @method int setnx(string $key, $value) From d2011405e32cd47968e62c069fab275f9cde01d8 Mon Sep 17 00:00:00 2001 From: Martin Modler Date: Mon, 18 Sep 2023 09:08:01 +0200 Subject: [PATCH 23/23] Update Prefix.php - Re-added callable check, allow objects and closures --- src/Configuration/Option/Prefix.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configuration/Option/Prefix.php b/src/Configuration/Option/Prefix.php index a342cf177..e42248cae 100644 --- a/src/Configuration/Option/Prefix.php +++ b/src/Configuration/Option/Prefix.php @@ -29,7 +29,7 @@ class Prefix implements OptionInterface */ public function filter(OptionsInterface $options, $value) { - if ($value instanceof Closure) { + if (is_callable($value) && (is_object($value) || $value instanceof Closure)) { $value = call_user_func($value, $options); }