use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class ManagedChannelImplTest method nameResolverHelper_emptyConfigSucceeds.
@Test
public void nameResolverHelper_emptyConfigSucceeds() {
boolean retryEnabled = false;
int maxRetryAttemptsLimit = 2;
int maxHedgedAttemptsLimit = 3;
AutoConfiguredLoadBalancerFactory autoConfiguredLoadBalancerFactory = new AutoConfiguredLoadBalancerFactory("pick_first");
ScParser parser = new ScParser(retryEnabled, maxRetryAttemptsLimit, maxHedgedAttemptsLimit, autoConfiguredLoadBalancerFactory);
ConfigOrError coe = parser.parseServiceConfig(ImmutableMap.<String, Object>of());
assertThat(coe.getError()).isNull();
ManagedChannelServiceConfig cfg = (ManagedChannelServiceConfig) coe.getConfig();
assertThat(cfg.getMethodConfig(method)).isEqualTo(ManagedChannelServiceConfig.empty().getMethodConfig(method));
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class ManagedChannelImplTest method nameResolverHelper_badConfigFails.
@Test
public void nameResolverHelper_badConfigFails() {
boolean retryEnabled = false;
int maxRetryAttemptsLimit = 2;
int maxHedgedAttemptsLimit = 3;
AutoConfiguredLoadBalancerFactory autoConfiguredLoadBalancerFactory = new AutoConfiguredLoadBalancerFactory("pick_first");
ScParser parser = new ScParser(retryEnabled, maxRetryAttemptsLimit, maxHedgedAttemptsLimit, autoConfiguredLoadBalancerFactory);
ConfigOrError coe = parser.parseServiceConfig(ImmutableMap.<String, Object>of("methodConfig", "bogus"));
assertThat(coe.getError()).isNotNull();
assertThat(coe.getError().getCode()).isEqualTo(Code.UNKNOWN);
assertThat(coe.getError().getDescription()).contains("failed to parse service config");
assertThat(coe.getError().getCause()).isInstanceOf(ClassCastException.class);
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class ManagedChannelImplTest method nameResolverHelper_noConfigChosen.
@Test
public void nameResolverHelper_noConfigChosen() {
boolean retryEnabled = false;
int maxRetryAttemptsLimit = 2;
int maxHedgedAttemptsLimit = 3;
AutoConfiguredLoadBalancerFactory autoConfiguredLoadBalancerFactory = new AutoConfiguredLoadBalancerFactory("pick_first");
ScParser parser = new ScParser(retryEnabled, maxRetryAttemptsLimit, maxHedgedAttemptsLimit, autoConfiguredLoadBalancerFactory);
ConfigOrError coe = parser.parseServiceConfig(ImmutableMap.of("loadBalancingConfig", ImmutableList.of()));
assertThat(coe.getError()).isNull();
ManagedChannelServiceConfig cfg = (ManagedChannelServiceConfig) coe.getConfig();
assertThat(cfg.getLoadBalancingConfig()).isNull();
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class DnsNameResolverTest method parseServiceConfig_noChoiceIsNull.
@Test
public void parseServiceConfig_noChoiceIsNull() {
ConfigOrError result = DnsNameResolver.parseServiceConfig(Arrays.asList("grpc_config=[]"), new Random(), "localhost");
assertThat(result).isNull();
}
use of io.grpc.NameResolver.ConfigOrError in project grpc-java by grpc.
the class DnsNameResolverTest method parseServiceConfig_capturesParseError.
@Test
public void parseServiceConfig_capturesParseError() {
ConfigOrError result = DnsNameResolver.parseServiceConfig(Arrays.asList("grpc_config=bogus"), new Random(), "localhost");
assertThat(result).isNotNull();
assertThat(result.getError().getCode()).isEqualTo(Status.Code.UNKNOWN);
assertThat(result.getError().getDescription()).contains("failed to parse TXT records");
}
Aggregations