Added support for redis gears trigger function commands (#1348)

* Added support for redis gears trigger function commands

* Exclude gears tests from relay connection tests

* Codestyle fixes

* Added missing test coverage

* Updated method description

* Use redis-stack:edge image istead of separate container

* Updated RESP3 modules responses

* Removed redundant constants

* Added additional timeout to make sure that index was created

* Marked test as relay-incompatible

* Mark tests as relay-incompatible

* Mark tests as relay-incompatible

* Increase timeout after index creation

* Added support for trigger functions command run against OSS cluster

* Mark gears cluster tests with appropriate annotation

* Marked with cluster annotation

* Codestyle fixes

* Removed refresh cluster on connection, moved to refresh manually in tests

* Removed redundant test

* Updated README, added comments with README references

* Revert "Marked test as relay-incompatible"

This reverts commit d888968b7b.

* Revert changes

* Revert "Mark tests as relay-incompatible"

This reverts commit 7d34370c6b.

* Revert "Updated RESP3 modules responses"

This reverts commit 5cf122ad71.

* Removed latest image

* Updated RESP3 modules responses (#4)

* Marked tests as relay-incompatible (#3)

* Marked test as relay-incompatible

* Mark tests as relay-incompatible

* Mark tests as relay-incompatible

* Changed tests group for RESP3 not supported tests

* Fixed broken tests

* Removed redundant test

* Marked test as relay-incompatible

* Codestyle fixes

* Updated CHANGELOG.md

* Updated CHANGELOG.md

* Revert php-cs-fixer style changes

---------

Co-authored-by: Chayim <chayim@users.noreply.github.com>
This commit is contained in:
Vladyslav Vildanov
2023-11-01 18:09:09 +02:00
committed by GitHub
parent 2ae9af625c
commit 662fdb99b3
145 changed files with 1253 additions and 78 deletions
@@ -12,6 +12,7 @@
namespace Predis\Connection\Cluster;
use Predis\Command\CommandInterface;
use Predis\Connection\Parameters;
use PredisTestCase;
@@ -432,4 +433,42 @@ class PredisClusterTest extends PredisTestCase
$this->assertEquals($expectedParameters, $cluster->getParameters());
}
/**
* @group disconnected
*/
public function testExecuteCommandOnEachNode(): void
{
$mockCommand = $this->getMockBuilder(CommandInterface::class)->getMock();
$connection1 = $this->getMockConnection('tcp://127.0.0.1:7001');
$connection2 = $this->getMockConnection('tcp://127.0.0.1:7002');
$connection3 = $this->getMockConnection('tcp://127.0.0.1:7003');
$connection1
->expects($this->once())
->method('executeCommand')
->with($mockCommand)
->willReturn('response1');
$connection2
->expects($this->once())
->method('executeCommand')
->with($mockCommand)
->willReturn('response2');
$connection3
->expects($this->once())
->method('executeCommand')
->with($mockCommand)
->willReturn('response3');
$cluster = new PredisCluster(new Parameters());
$cluster->add($connection1);
$cluster->add($connection2);
$cluster->add($connection3);
$this->assertEquals(['response1', 'response2', 'response3'], $cluster->executeCommandOnEachNode($mockCommand));
}
}
@@ -16,6 +16,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use Predis\Cluster;
use Predis\Command;
use Predis\Connection;
use Predis\Connection\FactoryInterface;
use Predis\Connection\Parameters;
use Predis\Response;
use PredisTestCase;
@@ -137,14 +138,14 @@ class RedisClusterTest extends PredisTestCase
/**
* @group disconnected
*/
public function testConnectPicksRandomConnection(): void
public function testConnectToEachNode(): void
{
$connect1 = false;
$connect2 = false;
$connection1 = $this->getMockConnection('tcp://127.0.0.1:6379');
$connection1
->expects($this->any())
->expects($this->once())
->method('connect')
->willReturnCallback(function () use (&$connect1) {
$connect1 = true;
@@ -158,7 +159,7 @@ class RedisClusterTest extends PredisTestCase
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6380');
$connection2
->expects($this->any())
->expects($this->once())
->method('connect')
->willReturnCallback(function () use (&$connect2) {
$connect2 = true;
@@ -178,14 +179,8 @@ class RedisClusterTest extends PredisTestCase
$cluster->connect();
$this->assertTrue($cluster->isConnected());
if ($connect1) {
$this->assertTrue($connect1);
$this->assertFalse($connect2);
} else {
$this->assertFalse($connect1);
$this->assertTrue($connect2);
}
$this->assertTrue($connect1);
$this->assertTrue($connect2);
}
/**
@@ -1460,4 +1455,43 @@ class RedisClusterTest extends PredisTestCase
$this->assertEquals($expectedParameters, $cluster->getParameters());
}
/**
* @group disconnected
*/
public function testExecuteCommandOnEachNode(): void
{
$mockCommand = $this->getMockBuilder(Command\CommandInterface::class)->getMock();
$factory = $this->getMockBuilder(FactoryInterface::class)->getMock();
$connection1 = $this->getMockConnection('tcp://127.0.0.1:7001');
$connection2 = $this->getMockConnection('tcp://127.0.0.1:7002');
$connection3 = $this->getMockConnection('tcp://127.0.0.1:7003');
$connection1
->expects($this->once())
->method('executeCommand')
->with($mockCommand)
->willReturn('response1');
$connection2
->expects($this->once())
->method('executeCommand')
->with($mockCommand)
->willReturn('response2');
$connection3
->expects($this->once())
->method('executeCommand')
->with($mockCommand)
->willReturn('response3');
$cluster = new RedisCluster($factory, new Parameters());
$cluster->add($connection1);
$cluster->add($connection2);
$cluster->add($connection3);
$this->assertEquals(['response1', 'response2', 'response3'], $cluster->executeCommandOnEachNode($mockCommand));
}
}