use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class RingHashLoadBalancerProviderTest method parseLoadBalancingConfig_invalid_ringTooLarge.
@Test
public void parseLoadBalancingConfig_invalid_ringTooLarge() throws IOException {
long ringSize = RingHashLoadBalancerProvider.MAX_RING_SIZE + 1;
String lbConfig = String.format("{\"minRingSize\" : 10, \"maxRingSize\" : %d}", ringSize);
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getDescription()).isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class RingHashLoadBalancerProviderTest method parseLoadBalancingConfig_invalid_minGreaterThanMax.
@Test
public void parseLoadBalancingConfig_invalid_minGreaterThanMax() throws IOException {
String lbConfig = "{\"minRingSize\" : 1000, \"maxRingSize\" : 100}";
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getDescription()).isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class RingHashLoadBalancerProviderTest method parseLoadBalancingConfig_invalid_negativeSize.
@Test
public void parseLoadBalancingConfig_invalid_negativeSize() throws IOException {
String lbConfig = "{\"minRingSize\" : -10}";
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getDescription()).isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class LeastRequestLoadBalancerProviderTest method parseLoadBalancingConfig_invalidInteger.
@Test
public void parseLoadBalancingConfig_invalidInteger() throws IOException {
Map<String, ?> lbConfig = parseJsonObject("{\"choiceCount\" : \"NaN\"}");
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(lbConfig);
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getDescription()).isEqualTo("Failed to parse least_request_experimental LB config: " + lbConfig);
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class LeastRequestLoadBalancerProviderTest method parseLoadBalancingConfig_valid.
@Test
public void parseLoadBalancingConfig_valid() throws IOException {
String lbConfig = "{\"choiceCount\" : 3}";
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getConfig()).isNotNull();
LeastRequestConfig config = (LeastRequestConfig) configOrError.getConfig();
assertThat(config.choiceCount).isEqualTo(3);
}
Aggregations