From 30e54e217d3c2b7fbc0bb22ae1f33a1bfad4cac0 Mon Sep 17 00:00:00 2001 From: Arvind Bright Date: Thu, 2 May 2024 18:06:29 -0700 Subject: [PATCH 1/3] test: fix possible leaked goroutine in TestDetailedConnectionCloseErrorPropagatesToRpcError --- test/end2end_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/end2end_test.go b/test/end2end_test.go index 321aeb52d70e..441ba4647d0c 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -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{}) + close(rpcDoneOnClient) ss := &stubserver.StubServer{ FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { close(rpcStartedOnServer) @@ -1042,7 +1043,6 @@ func (s) TestDetailedConnectionCloseErrorPropagatesToRpcError(t *testing.T) { 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) { From 9efd28565086208f87527d7a751f6cb838eec92a Mon Sep 17 00:00:00 2001 From: Arvind Bright Date: Thu, 2 May 2024 18:09:36 -0700 Subject: [PATCH 2/3] fix comments to 80 cols and also defer close call --- test/end2end_test.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/end2end_test.go b/test/end2end_test.go index 441ba4647d0c..bd4342951315 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -1009,7 +1009,7 @@ func testServerGracefulStopIdempotent(t *testing.T, e env) { func (s) TestDetailedConnectionCloseErrorPropagatesToRpcError(t *testing.T) { rpcStartedOnServer := make(chan struct{}) rpcDoneOnClient := make(chan struct{}) - close(rpcDoneOnClient) + defer close(rpcDoneOnClient) ss := &stubserver.StubServer{ FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error { close(rpcStartedOnServer) @@ -1025,21 +1025,24 @@ 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 _, ", 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) } From 48b6f6aa7a1352ae984e832ca638970874fd7c35 Mon Sep 17 00:00:00 2001 From: Arvind Bright Date: Fri, 3 May 2024 10:55:29 -0700 Subject: [PATCH 3/3] rename testname per go style --- test/end2end_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/end2end_test.go b/test/end2end_test.go index bd4342951315..b16085398946 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -1006,7 +1006,7 @@ func testServerGracefulStopIdempotent(t *testing.T, e env) { } } -func (s) TestDetailedConnectionCloseErrorPropagatesToRpcError(t *testing.T) { +func (s) TestDetailedConnectionCloseErrorPropagatesToRPCError(t *testing.T) { rpcStartedOnServer := make(chan struct{}) rpcDoneOnClient := make(chan struct{}) defer close(rpcDoneOnClient)