Skip to content

Commit

Permalink
rename to assertWeightedTargetPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
dapengzhang0 committed Apr 3, 2020
1 parent 0d8b4ba commit a00ff60
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java
Expand Up @@ -428,11 +428,11 @@ public void resolve_resourceUpdated_multipleRoutes() {
String action4 = (String) routes.get(4).get("action");
assertCdsPolicy(actions.get(action0), "cluster-hello.googleapis.com");
assertCdsPolicy(actions.get(action1), "cluster-foo.googleapis.com");
assertRouteActionIsWeightedTargetPolicy(
assertWeightedTargetPolicy(
actions.get(action2),
ImmutableMap.of(
"cluster-hello.googleapis.com", 40, "cluster-hello2.googleapis.com", 60));
assertRouteActionIsWeightedTargetPolicy(
assertWeightedTargetPolicy(
actions.get(action3),
ImmutableMap.of(
"cluster-bar.googleapis.com", 30, "cluster-bar2.googleapis.com", 70));
Expand Down Expand Up @@ -488,8 +488,12 @@ private static void assertCdsPolicy(Map<String, ?> action, String clusterName) {
assertThat(rawConfigValues).containsExactly("cluster", clusterName);
}

/**
* Asserts that the given action contains a single weighted-target policy with the given cluster
* to weight mapping.
*/
@SuppressWarnings("unchecked")
private static void assertRouteActionIsWeightedTargetPolicy(
private static void assertWeightedTargetPolicy(
Map<String, ?> action, Map<String, Integer> clusterWeights) {
assertThat(action.keySet()).containsExactly("childPolicy");
Map<String, ?> lbConfig =
Expand All @@ -499,6 +503,10 @@ private static void assertRouteActionIsWeightedTargetPolicy(
assertWeightedTargetConfigClusterWeights(rawConfigValues, clusterWeights);
}

/**
* Asserts that the given raw config is a weighted-target config with the given cluster to weight
* mapping.
*/
@SuppressWarnings("unchecked")
private static void assertWeightedTargetConfigClusterWeights(
Map<String, ?> rawConfigValues, Map<String, Integer> clusterWeight) {
Expand Down

0 comments on commit a00ff60

Please sign in to comment.