Skip to content

Commit 9bc0579

Browse files
xgopilotpionxe
andcommitted
test(gateway): stabilize close stream interruption assertion
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: pionxe <148670367+pionxe@users.noreply.github.com>
1 parent a5548c9 commit 9bc0579

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

internal/gateway/network_server_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,17 @@ func TestNetworkServerCloseInterruptsStreams(t *testing.T) {
780780
t.Fatalf("close network server: %v", err)
781781
}
782782

783-
_ = wsConn.SetReadDeadline(time.Now().Add(300 * time.Millisecond))
784-
var wsRawMessage string
785-
if err := websocket.Message.Receive(wsConn, &wsRawMessage); err == nil {
783+
websocketClosed := false
784+
wsCloseDeadline := time.Now().Add(1200 * time.Millisecond)
785+
for time.Now().Before(wsCloseDeadline) {
786+
_ = wsConn.SetReadDeadline(time.Now().Add(200 * time.Millisecond))
787+
var wsRawMessage string
788+
if err := websocket.Message.Receive(wsConn, &wsRawMessage); err != nil {
789+
websocketClosed = true
790+
break
791+
}
792+
}
793+
if !websocketClosed {
786794
t.Fatal("expected websocket receive to fail after server close")
787795
}
788796

0 commit comments

Comments
 (0)