From e83e34be0b72a3015b03725947702ee3352eb80a Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Mon, 6 Mar 2023 13:57:32 -0800 Subject: [PATCH] xds/resolver/test: use a non-blocking send instead of closing the channel (#6082) --- xds/internal/resolver/xds_resolver_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xds/internal/resolver/xds_resolver_test.go b/xds/internal/resolver/xds_resolver_test.go index 80f7fb75b..1e7ae998a 100644 --- a/xds/internal/resolver/xds_resolver_test.go +++ b/xds/internal/resolver/xds_resolver_test.go @@ -463,12 +463,15 @@ func (s) TestResolverWatchCallbackAfterClose(t *testing.T) { // it receives a discovery request for a route configuration resource. And // the test goroutine signals the management server when the resolver is // closed. - waitForRouteConfigDiscoveryReqCh := make(chan struct{}) + waitForRouteConfigDiscoveryReqCh := make(chan struct{}, 1) waitForResolverCloseCh := make(chan struct{}) mgmtServer, err := e2e.StartManagementServer(e2e.ManagementServerOptions{ OnStreamRequest: func(_ int64, req *v3discoverypb.DiscoveryRequest) error { if req.GetTypeUrl() == version.V3RouteConfigURL { - close(waitForRouteConfigDiscoveryReqCh) + select { + case waitForRouteConfigDiscoveryReqCh <- struct{}{}: + default: + } <-waitForResolverCloseCh } return nil