use of io.lettuce.core.ReadFrom in project lettuce-core by lettuce-io.
the class MasterReplicaTest method noReplicaForRead.
@Test
void noReplicaForRead() {
connection.setReadFrom(new ReadFrom() {
@Override
public List<RedisNodeDescription> select(Nodes nodes) {
return Collections.emptyList();
}
});
assertThatThrownBy(() -> replicaCall(connection)).isInstanceOf(RedisException.class);
}
use of io.lettuce.core.ReadFrom in project lettuce-core by lettuce-io.
the class PooledClusterConnectionProviderUnitTests method shouldNotifyListerOnUncoveredReadSlotAfterSelection.
@Test
void shouldNotifyListerOnUncoveredReadSlotAfterSelection() {
sut.setReadFrom(new ReadFrom() {
@Override
public List<RedisNodeDescription> select(Nodes nodes) {
return Collections.emptyList();
}
});
sut.getConnectionAsync(Intent.READ, 2);
verify(clusterEventListener).onUncoveredSlot(2);
}
use of io.lettuce.core.ReadFrom in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv6RuleAnyNode.
@Test
void subnetIpv6RuleAnyNode() {
ReadFrom sut = ReadFrom.subnet("::/0");
RedisClusterNode node = createNodeWithHost("2001:db8:abcd:1000::");
List<RedisNodeDescription> result = sut.select(getNodes(node));
assertThat(result).hasSize(1).containsExactly(node);
}
use of io.lettuce.core.ReadFrom in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv4RuleAnyNode.
@Test
void subnetIpv4RuleAnyNode() {
ReadFrom sut = ReadFrom.subnet("0.0.0.0/0");
RedisClusterNode node = createNodeWithHost("192.0.2.1");
List<RedisNodeDescription> result = sut.select(getNodes(node));
assertThat(result).hasSize(1).containsExactly(node);
}
use of io.lettuce.core.ReadFrom in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv4Ipv6Mixed.
@Test
void subnetIpv4Ipv6Mixed() {
ReadFrom sut = ReadFrom.subnet("192.0.2.0/24", "2001:db8:abcd:0000::/52");
RedisClusterNode nodeInSubnetIpv4 = createNodeWithHost("192.0.2.1");
RedisClusterNode nodeNotInSubnetIpv4 = createNodeWithHost("198.51.100.1");
RedisClusterNode nodeInSubnetIpv6 = createNodeWithHost("2001:db8:abcd:0000::1");
RedisClusterNode nodeNotInSubnetIpv6 = createNodeWithHost("2001:db8:abcd:1000::");
List<RedisNodeDescription> result = sut.select(getNodes(nodeInSubnetIpv4, nodeNotInSubnetIpv4, nodeInSubnetIpv6, nodeNotInSubnetIpv6));
assertThat(result).hasSize(2).containsExactly(nodeInSubnetIpv4, nodeInSubnetIpv6);
}
Aggregations