MCPcopy
hub / github.com/grpc/grpc-go / TestLargeMessageSuspension

Method TestLargeMessageSuspension

internal/transport/transport_test.go:1077–1109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1075}
1076
1077func (s) TestLargeMessageSuspension(t *testing.T) {
1078 server, ct, cancel := setUp(t, 0, suspended)
1079 defer cancel()
1080 defer ct.Close(fmt.Errorf("closed manually by test"))
1081 defer server.stop()
1082 callHdr := &CallHdr{
1083 Host: "localhost",
1084 Method: "foo.Large",
1085 }
1086 // Set a long enough timeout for writing a large message out.
1087 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
1088 defer cancel()
1089 s, err := ct.NewStream(ctx, callHdr, nil)
1090 if err != nil {
1091 t.Fatalf("failed to open stream: %v", err)
1092 }
1093 // Write should not be done successfully due to flow control.
1094 msg := make([]byte, initialWindowSize*8)
1095 s.Write(nil, newBufferSlice(msg), &WriteOptions{})
1096 err = s.Write(nil, newBufferSlice(msg), &WriteOptions{Last: true})
1097 if err != errStreamDone {
1098 t.Fatalf("Write got %v, want io.EOF", err)
1099 }
1100 // The server will send an RST stream frame on observing the deadline
1101 // expiration making the client stream fail with a DeadlineExceeded status.
1102 _, err = s.readTo(make([]byte, 8))
1103 if st, ok := status.FromError(err); !ok || st.Code() != codes.DeadlineExceeded {
1104 t.Fatalf("Read got unexpected error: %v, want status with code %v", err, codes.DeadlineExceeded)
1105 }
1106 if got, want := s.Status().Code(), codes.DeadlineExceeded; got != want {
1107 t.Fatalf("Read got status %v with code %v, want %v", s.Status(), got, want)
1108 }
1109}
1110
1111func (s) TestMaxStreams(t *testing.T) {
1112 serverConfig := &ServerConfig{

Callers

nothing calls this directly

Calls 12

FromErrorFunction · 0.92
setUpFunction · 0.85
newBufferSliceFunction · 0.85
readToMethod · 0.80
CodeMethod · 0.80
StatusMethod · 0.80
CloseMethod · 0.65
ErrorfMethod · 0.65
stopMethod · 0.65
NewStreamMethod · 0.65
FatalfMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected