use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class GrpclbLoadBalancerProviderTest method retrieveModeFromLbConfig_emptyChildPolicyUseRoundRobin.
@Test
public void retrieveModeFromLbConfig_emptyChildPolicyUseRoundRobin() throws Exception {
String lbConfig = "{\"childPolicy\" : []}";
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getConfig()).isNotNull();
GrpclbConfig config = (GrpclbConfig) configOrError.getConfig();
assertThat(config.getMode()).isEqualTo(Mode.ROUND_ROBIN);
assertThat(config.getServiceName()).isNull();
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class GrpclbLoadBalancerProviderTest method retrieveModeFromLbConfig_wrongChildPolicyTypeWithTarget.
@Test
public void retrieveModeFromLbConfig_wrongChildPolicyTypeWithTarget() throws Exception {
String lbConfig = "{\"childPolicy\" : {}, \"serviceName\": \"foo.google.com\"}";
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCause()).hasMessageThat().contains("is not List");
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class RlsLoadBalancerTest method deliverResolvedAddresses.
private void deliverResolvedAddresses() throws Exception {
ConfigOrError parsedConfigOrError = provider.parseLoadBalancingPolicyConfig(getServiceConfig());
assertThat(parsedConfigOrError.getConfig()).isNotNull();
rlsLb.handleResolvedAddresses(ResolvedAddresses.newBuilder().setAddresses(ImmutableList.of(new EquivalentAddressGroup(mock(SocketAddress.class)))).setLoadBalancingPolicyConfig(parsedConfigOrError.getConfig()).build());
verify(helper).createResolvingOobChannelBuilder(anyString(), any(ChannelCredentials.class));
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class LeastRequestLoadBalancerProviderTest method parseLoadBalancingConfig_invalid_negativeSize.
@Test
public void parseLoadBalancingConfig_invalid_negativeSize() throws IOException {
String lbConfig = "{\"choiceCount\" : -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 'choiceCount'");
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class LeastRequestLoadBalancerProviderTest method parseLoadBalancingConfig_missingChoiceCount_useDefaults.
@Test
public void parseLoadBalancingConfig_missingChoiceCount_useDefaults() throws IOException {
String lbConfig = "{}";
ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getConfig()).isNotNull();
LeastRequestConfig config = (LeastRequestConfig) configOrError.getConfig();
assertThat(config.choiceCount).isEqualTo(LeastRequestLoadBalancerProvider.DEFAULT_CHOICE_COUNT);
}
Aggregations