xds/resolver/test: use a non-blocking send instead of closing the channel (#6082)

This commit is contained in:
Easwar Swaminathan 2023-03-06 13:57:32 -08:00 committed by GitHub
parent b46bdef165
commit e83e34be0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -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