Vanillaxi commented on code in PR #3466:
URL: https://github.com/apache/dubbo-go/pull/3466#discussion_r3502940238


##########
protocol/triple/triple_protocol/stream_close_ext_test.go:
##########
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package triple_protocol_test
+
+import (
+       "context"
+       "errors"
+       "io"
+       "net/http"
+       "net/http/httptest"
+       "sync"
+       "testing"
+       "time"
+)
+
+import (
+       triple "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
+       
"dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol/internal/assert"
+       pingv1 
"dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol/internal/gen/proto/connect/ping/v1"
+       
"dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol/internal/gen/proto/connect/ping/v1/pingv1connect"
+)
+
+// TestServerStreamCloseDoesNotDrainResponse covers the public
+// ServerStreamForClient.Close path for connect-go#791-style lifecycle
+// behavior. The server sends one response and then intentionally keeps the
+// stream open; client-side Close should still return promptly because it is a
+// cleanup operation, not a request to read the stream to EOF.
+func TestServerStreamCloseDoesNotDrainResponse(t *testing.T) {
+       release, unblock := newCloseRelease()
+       t.Cleanup(unblock)
+       client := newCloseLifecyclePingClient(t, &pluggablePingServer{
+               countUp: func(ctx context.Context, req *triple.Request, stream 
*triple.ServerStream) error {
+                       if err := stream.Send(&pingv1.CountUpResponse{Number: 
1}); err != nil {
+                               return err
+                       }
+                       <-release
+                       return nil
+               },
+       })
+
+       stream, err := client.CountUp(context.Background(), 
triple.NewRequest(&pingv1.CountUpRequest{}))
+       assert.Nil(t, err)
+       assert.True(t, stream.Receive(&pingv1.CountUpResponse{}))

Review Comment:
   应该是这个测试的建模比较依赖调度顺序,我会先去把 setup 和 close assertion 拆开



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to