Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions provisionerd/provisionerd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ func createProvisionerDaemonClient(t *testing.T, server provisionerDaemonTestSer
err := proto.DRPCRegisterProvisionerDaemon(mux, &server)
require.NoError(t, err)
srv := drpcserver.New(mux)
ctx, cancelFunc := context.WithCancel(context.Background())
t.Cleanup(cancelFunc)
Comment on lines +409 to +410
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting... it's not clear to me how this will fix it, but I hope it does 🤞

It seems safe in any case, and it seems reasonable for this to be outside the func that starts the server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure either, but t.Cleanup certainly shouldn't be called async from my POV anyways.

go func() {
ctx, cancelFunc := context.WithCancel(context.Background())
t.Cleanup(cancelFunc)
_ = srv.Serve(ctx, serverPipe)
}()
return proto.NewDRPCProvisionerDaemonClient(provisionersdk.Conn(clientPipe))
Expand All @@ -426,9 +426,9 @@ func createProvisionerClient(t *testing.T, server provisionerTestServer) sdkprot
err := sdkproto.DRPCRegisterProvisioner(mux, &server)
require.NoError(t, err)
srv := drpcserver.New(mux)
ctx, cancelFunc := context.WithCancel(context.Background())
t.Cleanup(cancelFunc)
go func() {
ctx, cancelFunc := context.WithCancel(context.Background())
t.Cleanup(cancelFunc)
_ = srv.Serve(ctx, serverPipe)
}()
return sdkproto.NewDRPCProvisionerClient(provisionersdk.Conn(clientPipe))
Expand Down