Skip to content

Commit a41f75b

Browse files
committed
use SendContext to ensure no goroutine leaks
1 parent 7c9f578 commit a41f75b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

xds/internal/xdsclient/tests/ads_stream_ack_nack_test.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,11 @@ func (s) TestADS_ACK_NACK_Simple(t *testing.T) {
6060
streamResponseCh := testutils.NewChannel()
6161
mgmtServer := e2e.StartManagementServer(t, e2e.ManagementServerOptions{
6262
OnStreamRequest: func(_ int64, req *v3discoverypb.DiscoveryRequest) error {
63-
streamRequestCh.Send(req)
63+
streamRequestCh.SendContext(ctx, req)
6464
return nil
6565
},
6666
OnStreamResponse: func(_ context.Context, _ int64, _ *v3discoverypb.DiscoveryRequest, resp *v3discoverypb.DiscoveryResponse) {
67-
// The go-control-plane management server continuously resends the
68-
// same resource if NACKed by the client. Hence, we need to use
69-
// `Replace` here instead of `Send`.
70-
streamResponseCh.Replace(resp)
67+
streamResponseCh.SendContext(ctx, resp)
7168
},
7269
})
7370

@@ -242,11 +239,11 @@ func (s) TestADS_ACK_NACK_InvalidFirstResponse(t *testing.T) {
242239
streamResponseCh := testutils.NewChannel()
243240
mgmtServer := e2e.StartManagementServer(t, e2e.ManagementServerOptions{
244241
OnStreamRequest: func(_ int64, req *v3discoverypb.DiscoveryRequest) error {
245-
streamRequestCh.Send(req)
242+
streamRequestCh.SendContext(ctx, req)
246243
return nil
247244
},
248245
OnStreamResponse: func(_ context.Context, _ int64, _ *v3discoverypb.DiscoveryRequest, resp *v3discoverypb.DiscoveryResponse) {
249-
streamResponseCh.Send(resp)
246+
streamResponseCh.SendContext(ctx, resp)
250247
},
251248
})
252249

@@ -347,11 +344,11 @@ func (s) TestADS_ACK_NACK_ResourceIsNotRequestedAnymore(t *testing.T) {
347344
streamResponseCh := testutils.NewChannel()
348345
mgmtServer := e2e.StartManagementServer(t, e2e.ManagementServerOptions{
349346
OnStreamRequest: func(_ int64, req *v3discoverypb.DiscoveryRequest) error {
350-
streamRequestCh.Send(req)
347+
streamRequestCh.SendContext(ctx, req)
351348
return nil
352349
},
353350
OnStreamResponse: func(_ context.Context, _ int64, _ *v3discoverypb.DiscoveryRequest, resp *v3discoverypb.DiscoveryResponse) {
354-
streamResponseCh.Send(resp)
351+
streamResponseCh.SendContext(ctx, resp)
355352
},
356353
})
357354

0 commit comments

Comments
 (0)