@@ -414,19 +414,51 @@ public void discoverAggregateCluster_createsPriorityLbPolicy() {
414414
415415 String cluster1 = "cluster-01.googleapis.com" ;
416416 String cluster2 = "cluster-02.googleapis.com" ;
417+ String cluster3 = "cluster-03.googleapis.com" ;
418+ String cluster4 = "cluster-04.googleapis.com" ;
417419 controlPlaneService .setXdsConfig (ADS_TYPE_URL_CDS , ImmutableMap .of (
418- // CLUSTER (aggr.) -> [cluster1 (EDS ), cluster2 (EDS)]
420+ // CLUSTER (aggr.) -> [cluster1 (aggr. ), cluster2 (logical DNS), cluster3 (EDS)]
419421 CLUSTER , Cluster .newBuilder ()
420- .setName (CLUSTER )
421- .setClusterType (Cluster .CustomClusterType .newBuilder ()
422- .setName ("envoy.clusters.aggregate" )
423- .setTypedConfig (Any .pack (ClusterConfig .newBuilder ()
424- .addClusters (cluster1 )
425- .addClusters (cluster2 )
426- .build ())))
427- .build (),
428- cluster1 , EDS_CLUSTER .toBuilder ().setName (cluster1 ).build (),
429- cluster2 , EDS_CLUSTER .toBuilder ().setName (cluster2 ).build ()));
422+ .setName (CLUSTER )
423+ .setClusterType (Cluster .CustomClusterType .newBuilder ()
424+ .setName ("envoy.clusters.aggregate" )
425+ .setTypedConfig (Any .pack (ClusterConfig .newBuilder ()
426+ .addClusters (cluster1 )
427+ .addClusters (cluster2 )
428+ .addClusters (cluster3 )
429+ .build ())))
430+ .setLbPolicy (Cluster .LbPolicy .RING_HASH )
431+ .build (),
432+ // cluster1 (aggr.) -> [cluster3 (EDS), cluster4 (EDS)]
433+ cluster1 , Cluster .newBuilder ()
434+ .setName (cluster1 )
435+ .setClusterType (Cluster .CustomClusterType .newBuilder ()
436+ .setName ("envoy.clusters.aggregate" )
437+ .setTypedConfig (Any .pack (ClusterConfig .newBuilder ()
438+ .addClusters (cluster3 )
439+ .addClusters (cluster4 )
440+ .build ())))
441+ .build (),
442+ cluster2 , Cluster .newBuilder ()
443+ .setName (cluster2 )
444+ .setType (Cluster .DiscoveryType .LOGICAL_DNS )
445+ .setLoadAssignment (ClusterLoadAssignment .newBuilder ()
446+ .addEndpoints (LocalityLbEndpoints .newBuilder ()
447+ .addLbEndpoints (LbEndpoint .newBuilder ()
448+ .setEndpoint (Endpoint .newBuilder ()
449+ .setAddress (Address .newBuilder ()
450+ .setSocketAddress (SocketAddress .newBuilder ()
451+ .setAddress ("dns.example.com" )
452+ .setPortValue (1111 )))))))
453+ .build (),
454+ cluster3 , EDS_CLUSTER .toBuilder ()
455+ .setName (cluster3 )
456+ .setCircuitBreakers (CircuitBreakers .newBuilder ()
457+ .addThresholds (CircuitBreakers .Thresholds .newBuilder ()
458+ .setPriority (RoutingPriority .DEFAULT )
459+ .setMaxRequests (UInt32Value .newBuilder ().setValue (100 ))))
460+ .build (),
461+ cluster4 , EDS_CLUSTER .toBuilder ().setName (cluster4 ).build ()));
430462 startXdsDepManager ();
431463
432464 verify (helper , never ()).updateBalancingState (eq (ConnectivityState .TRANSIENT_FAILURE ), any ());
@@ -435,16 +467,23 @@ public void discoverAggregateCluster_createsPriorityLbPolicy() {
435467 assertThat (childBalancer .name ).isEqualTo (PRIORITY_POLICY_NAME );
436468 PriorityLoadBalancerProvider .PriorityLbConfig childLbConfig =
437469 (PriorityLoadBalancerProvider .PriorityLbConfig ) childBalancer .config ;
438- assertThat (childLbConfig .priorities ).hasSize (2 );
439- assertThat (childLbConfig .priorities .get (0 )).isEqualTo (cluster1 );
440- assertThat (childLbConfig .priorities .get (1 )).isEqualTo (cluster2 );
441- assertThat (childLbConfig .childConfigs ).hasSize (2 );
442- PriorityLoadBalancerProvider .PriorityLbConfig .PriorityChildConfig childConfig1 =
443- childLbConfig .childConfigs .get (cluster1 );
444- assertThat (childConfig1 .toString ()).isEqualTo ("PriorityChildConfig{childConfig="
470+ assertThat (childLbConfig .priorities ).hasSize (3 );
471+ assertThat (childLbConfig .priorities .get (0 )).isEqualTo (cluster3 );
472+ assertThat (childLbConfig .priorities .get (1 )).isEqualTo (cluster4 );
473+ assertThat (childLbConfig .priorities .get (2 )).isEqualTo (cluster2 );
474+ assertThat (childLbConfig .childConfigs ).hasSize (3 );
475+ PriorityLoadBalancerProvider .PriorityLbConfig .PriorityChildConfig childConfig3 =
476+ childLbConfig .childConfigs .get (cluster3 );
477+ assertThat (childConfig3 .toString ()).isEqualTo ("PriorityChildConfig{childConfig="
478+ + "GracefulSwitchLoadBalancer.Config{childFactory=CdsLoadBalancerProvider{"
479+ + "policy=cds_experimental, priority=5, available=true}, childConfig=CdsConfig{"
480+ + "name=cluster-03.googleapis.com, isDynamic=false}}, ignoreReresolution=false}" );
481+ PriorityLoadBalancerProvider .PriorityLbConfig .PriorityChildConfig childConfig4 =
482+ childLbConfig .childConfigs .get (cluster4 );
483+ assertThat (childConfig4 .toString ()).isEqualTo ("PriorityChildConfig{childConfig="
445484 + "GracefulSwitchLoadBalancer.Config{childFactory=CdsLoadBalancerProvider{"
446485 + "policy=cds_experimental, priority=5, available=true}, childConfig=CdsConfig{"
447- + "name=cluster-01 .googleapis.com, isDynamic=false}}, ignoreReresolution=false}" );
486+ + "name=cluster-04 .googleapis.com, isDynamic=false}}, ignoreReresolution=false}" );
448487 PriorityLoadBalancerProvider .PriorityLbConfig .PriorityChildConfig childConfig2 =
449488 childLbConfig .childConfigs .get (cluster2 );
450489 assertThat (childConfig2 .toString ()).isEqualTo ("PriorityChildConfig{childConfig="
0 commit comments