use of io.envoyproxy.envoy.config.cluster.v3.Cluster in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseCluster_ringHashLbPolicy_defaultLbConfig.
@Test
public void parseCluster_ringHashLbPolicy_defaultLbConfig() throws ResourceInvalidException {
Cluster cluster = Cluster.newBuilder().setName("cluster-foo.googleapis.com").setType(DiscoveryType.EDS).setEdsClusterConfig(EdsClusterConfig.newBuilder().setEdsConfig(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance())).setServiceName("service-foo.googleapis.com")).setLbPolicy(LbPolicy.RING_HASH).build();
CdsUpdate update = ClientXdsClient.processCluster(cluster, new HashSet<String>(), null, LRS_SERVER_INFO);
assertThat(update.lbPolicy()).isEqualTo(CdsUpdate.LbPolicy.RING_HASH);
assertThat(update.minRingSize()).isEqualTo(ClientXdsClient.DEFAULT_RING_HASH_LB_POLICY_MIN_RING_SIZE);
assertThat(update.maxRingSize()).isEqualTo(ClientXdsClient.DEFAULT_RING_HASH_LB_POLICY_MAX_RING_SIZE);
}
use of io.envoyproxy.envoy.config.cluster.v3.Cluster in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseCluster_ringHashLbPolicy_invalidRingSizeConfig_tooLargeRingSize.
@Test
public void parseCluster_ringHashLbPolicy_invalidRingSizeConfig_tooLargeRingSize() throws ResourceInvalidException {
Cluster cluster = Cluster.newBuilder().setName("cluster-foo.googleapis.com").setType(DiscoveryType.EDS).setEdsClusterConfig(EdsClusterConfig.newBuilder().setEdsConfig(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance())).setServiceName("service-foo.googleapis.com")).setLbPolicy(LbPolicy.RING_HASH).setRingHashLbConfig(RingHashLbConfig.newBuilder().setHashFunction(HashFunction.XX_HASH).setMinimumRingSize(UInt64Value.newBuilder().setValue(1000L)).setMaximumRingSize(UInt64Value.newBuilder().setValue(ClientXdsClient.MAX_RING_HASH_LB_POLICY_RING_SIZE + 1))).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("Cluster cluster-foo.googleapis.com: invalid ring_hash_lb_config");
ClientXdsClient.processCluster(cluster, new HashSet<String>(), null, LRS_SERVER_INFO);
}
use of io.envoyproxy.envoy.config.cluster.v3.Cluster in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseCluster_leastRequestLbPolicy_invalidChoiceCountConfig_tooSmallChoiceCount.
@Test
public void parseCluster_leastRequestLbPolicy_invalidChoiceCountConfig_tooSmallChoiceCount() throws ResourceInvalidException {
ClientXdsClient.enableLeastRequest = true;
Cluster cluster = Cluster.newBuilder().setName("cluster-foo.googleapis.com").setType(DiscoveryType.EDS).setEdsClusterConfig(EdsClusterConfig.newBuilder().setEdsConfig(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance())).setServiceName("service-foo.googleapis.com")).setLbPolicy(LbPolicy.LEAST_REQUEST).setLeastRequestLbConfig(LeastRequestLbConfig.newBuilder().setChoiceCount(UInt32Value.newBuilder().setValue(1))).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("Cluster cluster-foo.googleapis.com: invalid least_request_lb_config");
ClientXdsClient.processCluster(cluster, new HashSet<String>(), null, LRS_SERVER_INFO);
}
use of io.envoyproxy.envoy.config.cluster.v3.Cluster in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseCluster_transportSocketMatches_exception.
@Test
public void parseCluster_transportSocketMatches_exception() throws ResourceInvalidException {
Cluster cluster = Cluster.newBuilder().setName("cluster-foo.googleapis.com").setType(DiscoveryType.EDS).setEdsClusterConfig(EdsClusterConfig.newBuilder().setEdsConfig(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance())).setServiceName("service-foo.googleapis.com")).setLbPolicy(LbPolicy.ROUND_ROBIN).addTransportSocketMatches(Cluster.TransportSocketMatch.newBuilder().setName("match1").build()).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("Cluster cluster-foo.googleapis.com: transport-socket-matches not supported.");
ClientXdsClient.processCluster(cluster, new HashSet<String>(), null, LRS_SERVER_INFO);
}
use of io.envoyproxy.envoy.config.cluster.v3.Cluster in project grpc-java by grpc.
the class ClientXdsClientDataTest method parseCluster_ringHashLbPolicy_invalidRingSizeConfig_minGreaterThanMax.
@Test
public void parseCluster_ringHashLbPolicy_invalidRingSizeConfig_minGreaterThanMax() throws ResourceInvalidException {
Cluster cluster = Cluster.newBuilder().setName("cluster-foo.googleapis.com").setType(DiscoveryType.EDS).setEdsClusterConfig(EdsClusterConfig.newBuilder().setEdsConfig(ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance())).setServiceName("service-foo.googleapis.com")).setLbPolicy(LbPolicy.RING_HASH).setRingHashLbConfig(RingHashLbConfig.newBuilder().setHashFunction(HashFunction.XX_HASH).setMinimumRingSize(UInt64Value.newBuilder().setValue(1000L)).setMaximumRingSize(UInt64Value.newBuilder().setValue(100L))).build();
thrown.expect(ResourceInvalidException.class);
thrown.expectMessage("Cluster cluster-foo.googleapis.com: invalid ring_hash_lb_config");
ClientXdsClient.processCluster(cluster, new HashSet<String>(), null, LRS_SERVER_INFO);
}
Aggregations