|
31 | 31 | *
|
32 | 32 | * @author Christoph Strobl
|
33 | 33 | * @author Mark Paluch
|
| 34 | + * @author Sorokin Evgeniy |
34 | 35 | */
|
35 | 36 | class ConvertersUnitTests {
|
36 | 37 |
|
@@ -60,6 +61,12 @@ class ConvertersUnitTests {
|
60 | 61 |
|
61 | 62 | private static final String CLUSTER_NODE_WITHOUT_HOST = "ef570f86c7b1a953846668debc177a3a16733420 :6379 fail,master - 0 0 1 connected";
|
62 | 63 |
|
| 64 | + private static final String CLUSTER_NODE_WITH_SINGLE_IPV6_HOST = "67adfe3df1058896e3cb49d2863e0f70e7e159fa 2a02:6b8:c67:9c:0:6d8b:33da:5a2c:6380@16380,redis-master master,nofailover - 0 1692108412315 1 connected 0-5460"; |
| 65 | + |
| 66 | + private static final String CLUSTER_NODE_WITH_SINGLE_IPV6_HOST_SQUARE_BRACKETS = "67adfe3df1058896e3cb49d2863e0f70e7e159fa [2a02:6b8:c67:9c:0:6d8b:33da:5a2c]:6380@16380,redis-master master,nofailover - 0 1692108412315 1 connected 0-5460"; |
| 67 | + |
| 68 | + private static final String CLUSTER_NODE_WITH_SINGLE_INVALID_IPV6_HOST = "67adfe3df1058896e3cb49d2863e0f70e7e159fa 2a02:6b8:c67:9c:0:6d8b:33da:5a2c: master,nofailover - 0 1692108412315 1 connected 0-5460"; |
| 69 | + |
63 | 70 | @Test // DATAREDIS-315
|
64 | 71 | void toSetOfRedis30ClusterNodesShouldConvertSingleStringNodesResponseCorrectly() {
|
65 | 72 |
|
@@ -222,4 +229,36 @@ void toSetOfRedisClusterNodesShouldAllowEmptyHostname() {
|
222 | 229 | assertThat(node.getSlotRange().getSlots().size()).isEqualTo(0);
|
223 | 230 | }
|
224 | 231 |
|
| 232 | + @Test // https://github.com/spring-projects/spring-data-redis/issues/2678 |
| 233 | + void toClusterNodeWithIPv6Hostname() { |
| 234 | + RedisClusterNode node = Converters.toClusterNode(CLUSTER_NODE_WITH_SINGLE_IPV6_HOST); |
| 235 | + |
| 236 | + assertThat(node.getId()).isEqualTo("67adfe3df1058896e3cb49d2863e0f70e7e159fa"); |
| 237 | + assertThat(node.getHost()).isEqualTo("2a02:6b8:c67:9c:0:6d8b:33da:5a2c"); |
| 238 | + assertThat(node.hasValidHost()).isTrue(); |
| 239 | + assertThat(node.getPort()).isEqualTo(6380); |
| 240 | + assertThat(node.getType()).isEqualTo(NodeType.MASTER); |
| 241 | + assertThat(node.getFlags()).contains(Flag.MASTER); |
| 242 | + assertThat(node.getLinkState()).isEqualTo(LinkState.CONNECTED); |
| 243 | + assertThat(node.getSlotRange().getSlots().size()).isEqualTo(5461); |
| 244 | + } |
| 245 | + |
| 246 | + @Test // https://github.com/spring-projects/spring-data-redis/issues/2678 |
| 247 | + void toClusterNodeWithIPv6HostnameSquareBrackets() { |
| 248 | + RedisClusterNode node = Converters.toClusterNode(CLUSTER_NODE_WITH_SINGLE_IPV6_HOST_SQUARE_BRACKETS); |
| 249 | + |
| 250 | + assertThat(node.getId()).isEqualTo("67adfe3df1058896e3cb49d2863e0f70e7e159fa"); |
| 251 | + assertThat(node.getHost()).isEqualTo("2a02:6b8:c67:9c:0:6d8b:33da:5a2c"); |
| 252 | + assertThat(node.hasValidHost()).isTrue(); |
| 253 | + assertThat(node.getPort()).isEqualTo(6380); |
| 254 | + assertThat(node.getType()).isEqualTo(NodeType.MASTER); |
| 255 | + assertThat(node.getFlags()).contains(Flag.MASTER); |
| 256 | + assertThat(node.getLinkState()).isEqualTo(LinkState.CONNECTED); |
| 257 | + assertThat(node.getSlotRange().getSlots().size()).isEqualTo(5461); |
| 258 | + } |
| 259 | + |
| 260 | + @Test // https://github.com/spring-projects/spring-data-redis/issues/2678 |
| 261 | + void toClusterNodeWithInvalidIPv6Hostname() { |
| 262 | + assertThatIllegalArgumentException().isThrownBy(() -> Converters.toClusterNode(CLUSTER_NODE_WITH_SINGLE_INVALID_IPV6_HOST)); |
| 263 | + } |
225 | 264 | }
|
0 commit comments