|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Predis package. |
| 5 | + * |
| 6 | + * (c) 2009-2020 Daniele Alessandri |
| 7 | + * (c) 2021-2023 Till Krüss |
| 8 | + * |
| 9 | + * For the full copyright and license information, please view the LICENSE |
| 10 | + * file that was distributed with this source code. |
| 11 | + */ |
| 12 | + |
| 13 | +namespace Predis\Command\Redis; |
| 14 | + |
| 15 | +class CLUSTER_Test extends PredisCommandTestCase |
| 16 | +{ |
| 17 | + /** |
| 18 | + * {@inheritDoc} |
| 19 | + */ |
| 20 | + protected function getExpectedCommand(): string |
| 21 | + { |
| 22 | + return CLUSTER::class; |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * {@inheritDoc} |
| 27 | + */ |
| 28 | + protected function getExpectedId(): string |
| 29 | + { |
| 30 | + return 'CLUSTER'; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @group disconnected |
| 35 | + */ |
| 36 | + public function testFilterArgumentsOfAddSlotsRange(): void |
| 37 | + { |
| 38 | + $arguments = ['ADDSLOTSRANGE', 1, 1000]; |
| 39 | + $expected = ['ADDSLOTSRANGE', 1, 1000]; |
| 40 | + |
| 41 | + $command = $this->getCommand(); |
| 42 | + $command->setArguments($arguments); |
| 43 | + |
| 44 | + $this->assertSame($expected, $command->getArguments()); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @group disconnected |
| 49 | + */ |
| 50 | + public function testFilterArgumentsOfDelSlotsRange(): void |
| 51 | + { |
| 52 | + $arguments = ['DELSLOTSRANGE', 1, 1000]; |
| 53 | + $expected = ['DELSLOTSRANGE', 1, 1000]; |
| 54 | + |
| 55 | + $command = $this->getCommand(); |
| 56 | + $command->setArguments($arguments); |
| 57 | + |
| 58 | + $this->assertSame($expected, $command->getArguments()); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @group disconnected |
| 63 | + */ |
| 64 | + public function testFilterArgumentsOfLinks(): void |
| 65 | + { |
| 66 | + $arguments = ['LINKS']; |
| 67 | + $expected = ['LINKS']; |
| 68 | + |
| 69 | + $command = $this->getCommand(); |
| 70 | + $command->setArguments($arguments); |
| 71 | + |
| 72 | + $this->assertSame($expected, $command->getArguments()); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * @group disconnected |
| 77 | + */ |
| 78 | + public function testFilterArgumentsOfShards(): void |
| 79 | + { |
| 80 | + $arguments = ['SHARDS']; |
| 81 | + $expected = ['SHARDS']; |
| 82 | + |
| 83 | + $command = $this->getCommand(); |
| 84 | + $command->setArguments($arguments); |
| 85 | + |
| 86 | + $this->assertSame($expected, $command->getArguments()); |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * @group connected |
| 91 | + * @group cluster |
| 92 | + * @return void |
| 93 | + * @requiresRedisVersion >= 7.0.0 |
| 94 | + */ |
| 95 | + public function testAddSlotsRangeToGivenNode(): void |
| 96 | + { |
| 97 | + $redis = $this->getClient(); |
| 98 | + |
| 99 | + [$startSlot, $endSlot] = $redis->cluster->shards()[0][1]; |
| 100 | + |
| 101 | + $this->assertEquals('OK', $redis->cluster->delSlotsRange($startSlot, $endSlot)); |
| 102 | + $this->assertEquals('OK', $redis->cluster->addSlotsRange($startSlot, $endSlot)); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * @group connected |
| 107 | + * @group cluster |
| 108 | + * @return void |
| 109 | + * @requiresRedisVersion >= 7.0.0 |
| 110 | + */ |
| 111 | + public function testLinksReturnsClusterPeerLinks(): void |
| 112 | + { |
| 113 | + $redis = $this->getClient(); |
| 114 | + |
| 115 | + $this->assertNotEmpty($redis->cluster->links()); |
| 116 | + } |
| 117 | +} |
0 commit comments