use of io.grpc.xds.ClusterImplLoadBalancerProvider.ClusterImplConfig in project grpc-java by grpc.
the class ClusterResolverLoadBalancerTest method edsClustersWithLeastRequestEndpointLbPolicy.
@Test
public void edsClustersWithLeastRequestEndpointLbPolicy() {
ClusterResolverConfig config = new ClusterResolverConfig(Collections.singletonList(edsDiscoveryMechanism1), leastRequest);
deliverLbConfig(config);
assertThat(xdsClient.watchers.keySet()).containsExactly(EDS_SERVICE_NAME1);
assertThat(childBalancers).isEmpty();
// Simple case with one priority and one locality
EquivalentAddressGroup endpoint = makeAddress("endpoint-addr-1");
LocalityLbEndpoints localityLbEndpoints = LocalityLbEndpoints.create(Arrays.asList(LbEndpoint.create(endpoint, 0, /* loadBalancingWeight */
true)), 100, /* localityWeight */
1);
xdsClient.deliverClusterLoadAssignment(EDS_SERVICE_NAME1, ImmutableMap.of(locality1, localityLbEndpoints));
assertThat(childBalancers).hasSize(1);
FakeLoadBalancer childBalancer = Iterables.getOnlyElement(childBalancers);
assertThat(childBalancer.addresses).hasSize(1);
EquivalentAddressGroup addr = childBalancer.addresses.get(0);
assertThat(addr.getAddresses()).isEqualTo(endpoint.getAddresses());
assertThat(childBalancer.name).isEqualTo(PRIORITY_POLICY_NAME);
PriorityLbConfig priorityLbConfig = (PriorityLbConfig) childBalancer.config;
assertThat(priorityLbConfig.priorities).containsExactly(CLUSTER1 + "[priority1]");
PriorityChildConfig priorityChildConfig = Iterables.getOnlyElement(priorityLbConfig.childConfigs.values());
assertThat(priorityChildConfig.policySelection.getProvider().getPolicyName()).isEqualTo(CLUSTER_IMPL_POLICY_NAME);
ClusterImplConfig clusterImplConfig = (ClusterImplConfig) priorityChildConfig.policySelection.getConfig();
assertClusterImplConfig(clusterImplConfig, CLUSTER1, EDS_SERVICE_NAME1, LRS_SERVER_INFO, 100L, tlsContext, Collections.<DropOverload>emptyList(), WEIGHTED_TARGET_POLICY_NAME);
WeightedTargetConfig weightedTargetConfig = (WeightedTargetConfig) clusterImplConfig.childPolicy.getConfig();
assertThat(weightedTargetConfig.targets.keySet()).containsExactly(locality1.toString());
}
Aggregations