Skip to content

Commit f167ad6

Browse files
authored
test: fix possible leaked goroutine in TestDetailedConnectionCloseErrorPropagatesToRpcError (#7183)
1 parent bb9882e commit f167ad6

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

test/end2end_test.go

+14-11
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,10 @@ func testServerGracefulStopIdempotent(t *testing.T, e env) {
10061006
}
10071007
}
10081008

1009-
func (s) TestDetailedConnectionCloseErrorPropagatesToRpcError(t *testing.T) {
1009+
func (s) TestDetailedConnectionCloseErrorPropagatesToRPCError(t *testing.T) {
10101010
rpcStartedOnServer := make(chan struct{})
10111011
rpcDoneOnClient := make(chan struct{})
1012+
defer close(rpcDoneOnClient)
10121013
ss := &stubserver.StubServer{
10131014
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
10141015
close(rpcStartedOnServer)
@@ -1024,25 +1025,27 @@ func (s) TestDetailedConnectionCloseErrorPropagatesToRpcError(t *testing.T) {
10241025
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
10251026
defer cancel()
10261027

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

10481051
func (s) TestFailFast(t *testing.T) {

0 commit comments

Comments
 (0)