use of io.grpc.internal.ScParser in project grpc-java by grpc.
the class XdsNameResolverTest method retryPolicyInPerMethodConfigGeneratedByResolverIsValid.
@Test
public void retryPolicyInPerMethodConfigGeneratedByResolverIsValid() {
ServiceConfigParser realParser = new ScParser(true, 5, 5, new AutoConfiguredLoadBalancerFactory("pick-first"));
resolver = new XdsNameResolver(null, AUTHORITY, realParser, syncContext, scheduler, xdsClientPoolFactory, mockRandom, FilterRegistry.getDefaultRegistry(), null);
resolver.start(mockListener);
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
RetryPolicy retryPolicy = RetryPolicy.create(4, ImmutableList.of(Code.UNAVAILABLE), Durations.fromMillis(100), Durations.fromMillis(200), null);
xdsClient.deliverLdsUpdate(Collections.singletonList(Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster(cluster1, Collections.<HashPolicy>emptyList(), null, retryPolicy), ImmutableMap.<String, FilterConfig>of())));
verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue();
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
Result selectResult = configSelector.selectConfig(new PickSubchannelArgsImpl(call1.methodDescriptor, new Metadata(), CallOptions.DEFAULT));
Object config = selectResult.getConfig();
// Purely validating the data (io.grpc.internal.RetryPolicy).
// However, there's no public accessor methods the data object.
assertThat(config.getClass().getName()).isEqualTo("io.grpc.internal.ManagedChannelServiceConfig");
assertThat(config.toString()).contains(MoreObjects.toStringHelper("RetryPolicy").add("maxAttempts", 4).add("initialBackoffNanos", TimeUnit.MILLISECONDS.toNanos(100)).add("maxBackoffNanos", TimeUnit.MILLISECONDS.toNanos(200)).add("backoffMultiplier", 2D).add("perAttemptRecvTimeoutNanos", null).add("retryableStatusCodes", ImmutableList.of(Code.UNAVAILABLE)).toString());
}
Aggregations