Search in sources :

Example 6 with Cluster

use of com.google.bigtable.admin.v2.Cluster in project grpc-java by grpc.

the class LoadBalancerConfigFactoryTest method leastRequest_legacy.

@Test
public void leastRequest_legacy() throws ResourceInvalidException {
    System.setProperty("io.grpc.xds.experimentalEnableLeastRequest", "true");
    Cluster cluster = Cluster.newBuilder().setLbPolicy(LbPolicy.LEAST_REQUEST).setLeastRequestLbConfig(LeastRequestLbConfig.newBuilder().setChoiceCount(UInt32Value.of(10))).build();
    LbConfig lbConfig = newLbConfig(cluster, true, true);
    assertThat(lbConfig.getPolicyName()).isEqualTo("wrr_locality_experimental");
    List<LbConfig> childConfigs = ServiceConfigUtil.unwrapLoadBalancingConfigList(JsonUtil.getListOfObjects(lbConfig.getRawConfigValue(), "childPolicy"));
    assertThat(childConfigs.get(0).getPolicyName()).isEqualTo("least_request_experimental");
    assertThat(JsonUtil.getNumberAsLong(childConfigs.get(0).getRawConfigValue(), "choiceCount")).isEqualTo(10);
}
Also used : LbConfig(io.grpc.internal.ServiceConfigUtil.LbConfig) LeastRequestLbConfig(io.envoyproxy.envoy.config.cluster.v3.Cluster.LeastRequestLbConfig) RingHashLbConfig(io.envoyproxy.envoy.config.cluster.v3.Cluster.RingHashLbConfig) Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 7 with Cluster

use of com.google.bigtable.admin.v2.Cluster in project grpc-java by grpc.

the class LoadBalancerConfigFactoryTest method customLbInWrr_providerNotRegistered.

// When a provider for the custom wrr_locality child policy is NOT available, we should fall back
// to the round_robin that is also provided.
@Test
public void customLbInWrr_providerNotRegistered() throws ResourceInvalidException {
    Cluster cluster = Cluster.newBuilder().setLoadBalancingPolicy(LoadBalancingPolicy.newBuilder().addPolicies(buildWrrPolicy(CUSTOM_POLICY, ROUND_ROBIN_POLICY))).build();
    assertThat(newLbConfig(cluster, false, true)).isEqualTo(VALID_ROUND_ROBIN_CONFIG);
}
Also used : Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 8 with Cluster

use of com.google.bigtable.admin.v2.Cluster in project grpc-java by grpc.

the class LoadBalancerConfigFactoryTest method roundRobin_legacy.

@Test
public void roundRobin_legacy() throws ResourceInvalidException {
    Cluster cluster = Cluster.newBuilder().setLbPolicy(LbPolicy.ROUND_ROBIN).build();
    assertThat(newLbConfig(cluster, true, true)).isEqualTo(VALID_ROUND_ROBIN_CONFIG);
}
Also used : Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 9 with Cluster

use of com.google.bigtable.admin.v2.Cluster in project grpc-java by grpc.

the class LoadBalancerConfigFactoryTest method customLbInWrr_providerRegistered_udpa.

// When a provider for the endpoint picking custom policy is available, the configuration should
// use it. This one uses the legacy UDPA TypedStruct that is also supported.
@Test
public void customLbInWrr_providerRegistered_udpa() throws ResourceInvalidException {
    LoadBalancerRegistry.getDefaultRegistry().register(CUSTOM_POLICY_PROVIDER);
    Cluster cluster = Cluster.newBuilder().setLoadBalancingPolicy(LoadBalancingPolicy.newBuilder().addPolicies(buildWrrPolicy(CUSTOM_POLICY_UDPA, ROUND_ROBIN_POLICY))).build();
    assertThat(newLbConfig(cluster, false, true)).isEqualTo(VALID_CUSTOM_CONFIG_IN_WRR);
}
Also used : Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Example 10 with Cluster

use of com.google.bigtable.admin.v2.Cluster in project grpc-java by grpc.

the class LoadBalancerConfigFactoryTest method maxRecursion.

@Test
public void maxRecursion() {
    Cluster cluster = Cluster.newBuilder().setLoadBalancingPolicy(LoadBalancingPolicy.newBuilder().addPolicies(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(buildWrrPolicy(ROUND_ROBIN_POLICY))))))))))))))))))).build();
    assertResourceInvalidExceptionThrown(cluster, false, true, "Maximum LB config recursion depth reached");
}
Also used : Cluster(io.envoyproxy.envoy.config.cluster.v3.Cluster) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)93 AbstractMessage (com.google.protobuf.AbstractMessage)38 ByteString (com.google.protobuf.ByteString)32 Cluster (io.envoyproxy.envoy.config.cluster.v3.Cluster)25 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)24 StatusRuntimeException (io.grpc.StatusRuntimeException)24 ExecutionException (java.util.concurrent.ExecutionException)22 Cluster (com.google.cloud.dataproc.v1.Cluster)18 Operation (com.google.longrunning.Operation)18 Cluster (com.google.bigtable.admin.v2.Cluster)16 ClusterName (com.google.bigtable.admin.v2.ClusterName)16 ArrayList (java.util.ArrayList)16 ClusterOperationMetadata (com.google.cloud.dataproc.v1.ClusterOperationMetadata)13 HashMap (java.util.HashMap)13 Cluster (com.google.container.v1.Cluster)12 ClusterControllerClient (com.google.cloud.dataproc.v1.ClusterControllerClient)11 ClusterControllerSettings (com.google.cloud.dataproc.v1.ClusterControllerSettings)11 SoftwareConfig (com.google.cloud.dataproc.v1.SoftwareConfig)9 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)8 ClusterConfig (com.google.cloud.dataproc.v1.ClusterConfig)8