|
58 | 58 | import io.grpc.xds.LeastRequestLoadBalancer.LeastRequestConfig; |
59 | 59 | import io.grpc.xds.RingHashLoadBalancer.RingHashConfig; |
60 | 60 | import io.grpc.xds.XdsClusterResource.CdsUpdate; |
| 61 | +import io.grpc.xds.client.Bootstrapper.BootstrapInfo; |
61 | 62 | import io.grpc.xds.client.Bootstrapper.ServerInfo; |
| 63 | +import io.grpc.xds.client.EnvoyProtoData; |
62 | 64 | import io.grpc.xds.client.XdsClient; |
63 | 65 | import io.grpc.xds.client.XdsResourceType; |
64 | 66 | import io.grpc.xds.internal.security.CommonTlsContextTestsUtil; |
@@ -94,6 +96,16 @@ public class CdsLoadBalancer2Test { |
94 | 96 | private static final String DNS_HOST_NAME = "backend-service-dns.googleapis.com:443"; |
95 | 97 | private static final ServerInfo LRS_SERVER_INFO = |
96 | 98 | ServerInfo.create("lrs.googleapis.com", InsecureChannelCredentials.create()); |
| 99 | + private static final String SERVER_URI = "trafficdirector.googleapis.com"; |
| 100 | + private static final String NODE_ID = |
| 101 | + "projects/42/networks/default/nodes/5c85b298-6f5b-4722-b74a-f7d1f0ccf5ad"; |
| 102 | + private static final EnvoyProtoData.Node BOOTSTRAP_NODE = |
| 103 | + EnvoyProtoData.Node.newBuilder().setId(NODE_ID).build(); |
| 104 | + private static final BootstrapInfo BOOTSTRAP_INFO = BootstrapInfo.builder() |
| 105 | + .servers(ImmutableList.of( |
| 106 | + ServerInfo.create(SERVER_URI, InsecureChannelCredentials.create()))) |
| 107 | + .node(BOOTSTRAP_NODE) |
| 108 | + .build(); |
97 | 109 | private final UpstreamTlsContext upstreamTlsContext = |
98 | 110 | CommonTlsContextTestsUtil.buildUpstreamTlsContext("google_cloud_private_spiffe", true); |
99 | 111 | private final OutlierDetection outlierDetection = OutlierDetection.create( |
@@ -211,7 +223,8 @@ public void nonAggregateCluster_resourceNotExist_returnErrorPicker() { |
211 | 223 | verify(helper).updateBalancingState( |
212 | 224 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
213 | 225 | Status unavailable = Status.UNAVAILABLE.withDescription( |
214 | | - "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER); |
| 226 | + "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER |
| 227 | + + " xDS node ID: " + NODE_ID); |
215 | 228 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
216 | 229 | assertThat(childBalancers).isEmpty(); |
217 | 230 | } |
@@ -254,7 +267,8 @@ public void nonAggregateCluster_resourceRevoked() { |
254 | 267 | xdsClient.deliverResourceNotExist(CLUSTER); |
255 | 268 | assertThat(childBalancer.shutdown).isTrue(); |
256 | 269 | Status unavailable = Status.UNAVAILABLE.withDescription( |
257 | | - "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER); |
| 270 | + "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER |
| 271 | + + " xDS node ID: " + NODE_ID); |
258 | 272 | verify(helper).updateBalancingState( |
259 | 273 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
260 | 274 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
@@ -331,7 +345,8 @@ public void aggregateCluster_noNonAggregateClusterExits_returnErrorPicker() { |
331 | 345 | verify(helper).updateBalancingState( |
332 | 346 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
333 | 347 | Status unavailable = Status.UNAVAILABLE.withDescription( |
334 | | - "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER); |
| 348 | + "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER |
| 349 | + + " xDS node ID: " + NODE_ID); |
335 | 350 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
336 | 351 | assertThat(childBalancers).isEmpty(); |
337 | 352 | } |
@@ -379,7 +394,8 @@ public void aggregateCluster_descendantClustersRevoked() { |
379 | 394 | verify(helper).updateBalancingState( |
380 | 395 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
381 | 396 | Status unavailable = Status.UNAVAILABLE.withDescription( |
382 | | - "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER); |
| 397 | + "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER |
| 398 | + + " xDS node ID: " + NODE_ID); |
383 | 399 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
384 | 400 | assertThat(childBalancer.shutdown).isTrue(); |
385 | 401 | assertThat(childBalancers).isEmpty(); |
@@ -418,7 +434,8 @@ public void aggregateCluster_rootClusterRevoked() { |
418 | 434 | verify(helper).updateBalancingState( |
419 | 435 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
420 | 436 | Status unavailable = Status.UNAVAILABLE.withDescription( |
421 | | - "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER); |
| 437 | + "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER |
| 438 | + + " xDS node ID: " + NODE_ID); |
422 | 439 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
423 | 440 | assertThat(childBalancer.shutdown).isTrue(); |
424 | 441 | assertThat(childBalancers).isEmpty(); |
@@ -466,7 +483,8 @@ public void aggregateCluster_intermediateClusterChanges() { |
466 | 483 | verify(helper).updateBalancingState( |
467 | 484 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
468 | 485 | Status unavailable = Status.UNAVAILABLE.withDescription( |
469 | | - "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER); |
| 486 | + "CDS error: found 0 leaf (logical DNS or EDS) clusters for root cluster " + CLUSTER |
| 487 | + + " xDS node ID: " + NODE_ID); |
470 | 488 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
471 | 489 | assertThat(childBalancer.shutdown).isTrue(); |
472 | 490 | assertThat(childBalancers).isEmpty(); |
@@ -507,7 +525,7 @@ public void aggregateCluster_withLoops() { |
507 | 525 | Status unavailable = Status.UNAVAILABLE.withDescription( |
508 | 526 | "CDS error: circular aggregate clusters directly under cluster-02.googleapis.com for root" |
509 | 527 | + " cluster cluster-foo.googleapis.com, named [cluster-01.googleapis.com," |
510 | | - + " cluster-02.googleapis.com]"); |
| 528 | + + " cluster-02.googleapis.com], xDS node ID: " + NODE_ID); |
511 | 529 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
512 | 530 | } |
513 | 531 |
|
@@ -549,7 +567,7 @@ public void aggregateCluster_withLoops_afterEds() { |
549 | 567 | Status unavailable = Status.UNAVAILABLE.withDescription( |
550 | 568 | "CDS error: circular aggregate clusters directly under cluster-02.googleapis.com for root" |
551 | 569 | + " cluster cluster-foo.googleapis.com, named [cluster-01.googleapis.com," |
552 | | - + " cluster-02.googleapis.com]"); |
| 570 | + + " cluster-02.googleapis.com], xDS node ID: " + NODE_ID); |
553 | 571 | assertPicker(pickerCaptor.getValue(), unavailable, null); |
554 | 572 | } |
555 | 573 |
|
@@ -617,7 +635,7 @@ public void aggregateCluster_discoveryErrorBeforeChildLbCreated_returnErrorPicke |
617 | 635 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
618 | 636 | Status expectedError = Status.UNAVAILABLE.withDescription( |
619 | 637 | "Unable to load CDS cluster-foo.googleapis.com. xDS server returned: " |
620 | | - + "RESOURCE_EXHAUSTED: OOM"); |
| 638 | + + "RESOURCE_EXHAUSTED: OOM xDS node ID: " + NODE_ID); |
621 | 639 | assertPicker(pickerCaptor.getValue(), expectedError, null); |
622 | 640 | assertThat(childBalancers).isEmpty(); |
623 | 641 | } |
@@ -647,7 +665,8 @@ public void aggregateCluster_discoveryErrorAfterChildLbCreated_propagateToChildL |
647 | 665 |
|
648 | 666 | @Test |
649 | 667 | public void handleNameResolutionErrorFromUpstream_beforeChildLbCreated_returnErrorPicker() { |
650 | | - Status upstreamError = Status.UNAVAILABLE.withDescription("unreachable"); |
| 668 | + Status upstreamError = Status.UNAVAILABLE.withDescription( |
| 669 | + "unreachable xDS node ID: " + NODE_ID); |
651 | 670 | loadBalancer.handleNameResolutionError(upstreamError); |
652 | 671 | verify(helper).updateBalancingState( |
653 | 672 | eq(ConnectivityState.TRANSIENT_FAILURE), pickerCaptor.capture()); |
@@ -821,6 +840,11 @@ public <T extends ResourceUpdate> void cancelXdsResourceWatch(XdsResourceType<T> |
821 | 840 | } |
822 | 841 | } |
823 | 842 |
|
| 843 | + @Override |
| 844 | + public BootstrapInfo getBootstrapInfo() { |
| 845 | + return BOOTSTRAP_INFO; |
| 846 | + } |
| 847 | + |
824 | 848 | private void deliverCdsUpdate(String clusterName, CdsUpdate update) { |
825 | 849 | if (watchers.containsKey(clusterName)) { |
826 | 850 | List<ResourceWatcher<CdsUpdate>> resourceWatchers = |
|
0 commit comments