File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
internal/resolver/delegatingresolver Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -588,6 +588,10 @@ func (s) TestDelegatingResolverUpdateStateDuringClose(t *testing.T) {
588588 // Set up a manual DNS resolver to control the proxy address resolution.
589589 proxyResolver := setupDNS (t )
590590
591+ proxyResolverBuilt := make (chan struct {})
592+ proxyResolver .BuildCallback = func (resolver.Target , resolver.ClientConn , resolver.BuildOptions ) {
593+ close (proxyResolverBuilt )
594+ }
591595 unblockProxyResolverClose := make (chan struct {}, 1 )
592596 proxyResolver .CloseCallback = func () {
593597 <- unblockProxyResolverClose
@@ -607,11 +611,17 @@ func (s) TestDelegatingResolverUpdateStateDuringClose(t *testing.T) {
607611 Endpoints : []resolver.Endpoint {{Addresses : []resolver.Address {{Addr : "1.1.1.1" }}}},
608612 })
609613
614+ // Wait for the proxy resolver to be built before calling Close.
615+ ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
616+ defer cancel ()
617+ select {
618+ case <- proxyResolverBuilt :
619+ case <- ctx .Done ():
620+ t .Fatalf ("Context timed out waiting for proxy resolver to be built." )
621+ }
610622 // Closing the delegating resolver will block until the test writes to the
611623 // unblockProxyResolverClose channel.
612624 go dr .Close ()
613- ctx , cancel := context .WithTimeout (context .Background (), defaultTestTimeout )
614- defer cancel ()
615625 select {
616626 case <- targetResolverCloseCalled :
617627 case <- ctx .Done ():
You can’t perform that action at this time.
0 commit comments