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);
}
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);
}
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);
}
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);
}
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");
}
Aggregations