@@ -832,108 +832,3 @@ func (s) TestEDSPriority_FirstPriorityRemoved(t *testing.T) {
832832 t .Fatal (err )
833833 }
834834}
835-
836- // Watch resources from EDS and DNS, with EDS as the higher priority. Lower
837- // priority is used when higher priority is not ready.
838- func (s ) TestFallbackToDNS (t * testing.T ) {
839- const testDNSEndpointAddr = "3.1.4.1:5"
840- // dnsTargetCh, dnsCloseCh, resolveNowCh, dnsR, cleanup := setupDNS()
841- dnsTargetCh , _ , resolveNowCh , dnsR , cleanupDNS := setupDNS ()
842- defer cleanupDNS ()
843- edsb , cc , xdsC , cleanup := setupTestEDS (t , nil )
844- defer cleanup ()
845-
846- if err := edsb .UpdateClientConnState (balancer.ClientConnState {
847- BalancerConfig : & LBConfig {
848- DiscoveryMechanisms : []DiscoveryMechanism {
849- {
850- Type : DiscoveryMechanismTypeEDS ,
851- Cluster : testClusterName ,
852- },
853- {
854- Type : DiscoveryMechanismTypeLogicalDNS ,
855- DNSHostname : testDNSTarget ,
856- },
857- },
858- xdsLBPolicy : * wrrLocalityLBConfig ,
859- },
860- }); err != nil {
861- t .Fatal (err )
862- }
863-
864- ctx , ctxCancel := context .WithTimeout (context .Background (), defaultTestTimeout )
865- defer ctxCancel ()
866- select {
867- case target := <- dnsTargetCh :
868- if diff := cmp .Diff (target , resolver.Target {Scheme : "dns" , URL : * testutils .MustParseURL ("dns:///" + testDNSTarget )}); diff != "" {
869- t .Fatalf ("got unexpected DNS target to watch, diff (-got, +want): %v" , diff )
870- }
871- case <- ctx .Done ():
872- t .Fatal ("Timed out waiting for building DNS resolver" )
873- }
874-
875- // One locality with one backend.
876- clab1 := xdstestutils .NewClusterLoadAssignmentBuilder (testClusterNames [0 ], nil )
877- clab1 .AddLocality (testSubZones [0 ], 1 , 0 , testEndpointAddrs [:1 ], nil )
878- xdsC .InvokeWatchEDSCallback ("" , parseEDSRespProtoForTesting (clab1 .Build ()), nil )
879-
880- // Also send a DNS update, because the balancer needs both updates from all
881- // resources to move on.
882- dnsR .UpdateState (resolver.State {Addresses : []resolver.Address {{Addr : testDNSEndpointAddr }}})
883-
884- addrs0 := <- cc .NewSubConnAddrsCh
885- if got , want := addrs0 [0 ].Addr , testEndpointAddrs [0 ]; got != want {
886- t .Fatalf ("sc is created with addr %v, want %v" , got , want )
887- }
888- sc0 := <- cc .NewSubConnCh
889-
890- // p0 is ready.
891- edsb .UpdateSubConnState (sc0 , balancer.SubConnState {ConnectivityState : connectivity .Connecting })
892- edsb .UpdateSubConnState (sc0 , balancer.SubConnState {ConnectivityState : connectivity .Ready })
893-
894- // Test roundrobin with only p0 subconns.
895- if err := cc .WaitForRoundRobinPicker (ctx , sc0 ); err != nil {
896- t .Fatal (err )
897- }
898-
899- // Turn down 0, p1 (DNS) will be used.
900- edsb .UpdateSubConnState (sc0 , balancer.SubConnState {ConnectivityState : connectivity .TransientFailure })
901-
902- // The transient failure above should not trigger a re-resolve to the DNS
903- // resolver. Need to read to clear the channel, to avoid potential deadlock
904- // writing to the channel later.
905- shortCtx , shortCancel := context .WithTimeout (context .Background (), defaultTestShortTimeout )
906- defer shortCancel ()
907- select {
908- case <- resolveNowCh :
909- t .Fatal ("unexpected re-resolve trigger by transient failure from EDS endpoint" )
910- case <- shortCtx .Done ():
911- }
912-
913- // The addresses used to create new SubConn should be the DNS endpoint.
914- addrs1 := <- cc .NewSubConnAddrsCh
915- if got , want := addrs1 [0 ].Addr , testDNSEndpointAddr ; got != want {
916- t .Fatalf ("sc is created with addr %v, want %v" , got , want )
917- }
918- sc1 := <- cc .NewSubConnCh
919- edsb .UpdateSubConnState (sc1 , balancer.SubConnState {ConnectivityState : connectivity .Connecting })
920- edsb .UpdateSubConnState (sc1 , balancer.SubConnState {ConnectivityState : connectivity .Ready })
921-
922- // Test pick with 1.
923- if err := cc .WaitForRoundRobinPicker (ctx , sc1 ); err != nil {
924- t .Fatal (err )
925- }
926-
927- // Turn down the DNS endpoint, this should trigger an re-resolve in the DNS
928- // resolver.
929- edsb .UpdateSubConnState (sc1 , balancer.SubConnState {ConnectivityState : connectivity .TransientFailure })
930-
931- // The transient failure above should trigger a re-resolve to the DNS
932- // resolver. Need to read to clear the channel, to avoid potential deadlock
933- // writing to the channel later.
934- select {
935- case <- resolveNowCh :
936- case <- ctx .Done ():
937- t .Fatal ("Timed out waiting for re-resolve" )
938- }
939- }
0 commit comments