Search in sources :

Example 6 with Cluster

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);
}
Also used : WeightedCluster(io.envoyproxy.envoy.config.route.v3.WeightedCluster) Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) CdsUpdate(io.grpc.xds.XdsClient.CdsUpdate) Test(org.junit.Test)

Example 7 with Cluster

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);
}
Also used : WeightedCluster(io.envoyproxy.envoy.config.route.v3.WeightedCluster) Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 8 with Cluster

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);
}
Also used : WeightedCluster(io.envoyproxy.envoy.config.route.v3.WeightedCluster) Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 9 with Cluster

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);
}
Also used : WeightedCluster(io.envoyproxy.envoy.config.route.v3.WeightedCluster) Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 10 with Cluster

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);
}
Also used : WeightedCluster(io.envoyproxy.envoy.config.route.v3.WeightedCluster) Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Aggregations

Cluster (io.envoyproxy.envoy.config.cluster.v3.Cluster)10 Test (org.junit.Test)8 WeightedCluster (io.envoyproxy.envoy.config.route.v3.WeightedCluster)7 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 LbEndpoint (io.grpc.xds.Endpoints.LbEndpoint)3 CdsUpdate (io.grpc.xds.XdsClient.CdsUpdate)2 HashSet (java.util.HashSet)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Any (com.google.protobuf.Any)1 Thresholds (io.envoyproxy.envoy.config.cluster.v3.CircuitBreakers.Thresholds)1 CustomClusterType (io.envoyproxy.envoy.config.cluster.v3.Cluster.CustomClusterType)1 DiscoveryType (io.envoyproxy.envoy.config.cluster.v3.Cluster.DiscoveryType)1 LeastRequestLbConfig (io.envoyproxy.envoy.config.cluster.v3.Cluster.LeastRequestLbConfig)1 RingHashLbConfig (io.envoyproxy.envoy.config.cluster.v3.Cluster.RingHashLbConfig)1 SocketAddress (io.envoyproxy.envoy.config.core.v3.SocketAddress)1 ClusterLoadAssignment (io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment)1 DiscoveryResponse (io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse)1 ServerInfo (io.grpc.xds.Bootstrapper.ServerInfo)1 UpstreamTlsContext (io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext)1 ClientInterceptorBuilder (io.grpc.xds.Filter.ClientInterceptorBuilder)1