Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix possible leaked goroutine in TestDetailedConnectionCloseErrorPropagatesToRpcError #7183

Merged
Changes from 2 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
23 changes: 13 additions & 10 deletions test/end2end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ func testServerGracefulStopIdempotent(t *testing.T, e env) {
func (s) TestDetailedConnectionCloseErrorPropagatesToRpcError(t *testing.T) {
rpcStartedOnServer := make(chan struct{})
rpcDoneOnClient := make(chan struct{})
defer close(rpcDoneOnClient)
ss := &stubserver.StubServer{
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
close(rpcStartedOnServer)
Expand All @@ -1024,25 +1025,27 @@ func (s) TestDetailedConnectionCloseErrorPropagatesToRpcError(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()

// Start an RPC. Then, while the RPC is still being accepted or handled at the server, abruptly
// stop the server, killing the connection. The RPC error message should include details about the specific
// connection error that was encountered.
// Start an RPC. Then, while the RPC is still being accepted or handled at
// the server, abruptly stop the server, killing the connection. The RPC
// error message should include details about the specific connection error
// that was encountered.
stream, err := ss.Client.FullDuplexCall(ctx)
if err != nil {
t.Fatalf("%v.FullDuplexCall = _, %v, want _, <nil>", ss.Client, err)
}
// Block until the RPC has been started on the server. This ensures that the ClientConn will find a healthy
// connection for the RPC to go out on initially, and that the TCP connection will shut down strictly after
// the RPC has been started on it.
// Block until the RPC has been started on the server. This ensures that the
// ClientConn will find a healthy connection for the RPC to go out on
// initially, and that the TCP connection will shut down strictly after the
// RPC has been started on it.
<-rpcStartedOnServer
ss.S.Stop()
// The precise behavior of this test is subject to raceyness around the timing
// of when TCP packets are sent from client to server, and when we tell the
// server to stop, so we need to account for both possible error messages.
// The precise behavior of this test is subject to raceyness around the
// timing of when TCP packets are sent from client to server, and when we
// tell the server to stop, so we need to account for both possible error
// messages.
if _, err := stream.Recv(); err == io.EOF || !isConnClosedErr(err) {
t.Fatalf("%v.Recv() = _, %v, want _, rpc error containing substring: %q OR %q", stream, err, possibleConnResetMsg, possibleEOFMsg)
}
close(rpcDoneOnClient)
}

func (s) TestFailFast(t *testing.T) {
Expand Down
Loading