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

Method TestLargeMessageWithDelayRead

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

Source from the content-addressed store, hash-verified

901}
902
903func (s) TestLargeMessageWithDelayRead(t *testing.T) {
904 // Disable dynamic flow control.
905 sc := &ServerConfig{
906 BufferPool: mem.DefaultBufferPool(),
907 InitialWindowSize: defaultWindowSize,
908 InitialConnWindowSize: defaultWindowSize,
909 StaticWindowSize: true,
910 }
911 co := ConnectOptions{
912 InitialWindowSize: defaultWindowSize,
913 InitialConnWindowSize: defaultWindowSize,
914 StaticWindowSize: true,
915 BufferPool: mem.DefaultBufferPool(),
916 }
917 server, ct, cancel := setUpWithOptions(t, 0, sc, delayRead, co)
918 defer cancel()
919 defer server.stop()
920 defer ct.Close(fmt.Errorf("closed manually by test"))
921 server.mu.Lock()
922 ready := server.ready
923 server.mu.Unlock()
924 callHdr := &CallHdr{
925 Host: "localhost",
926 Method: "foo.Large",
927 }
928 ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
929 defer cancel()
930 s, err := ct.NewStream(ctx, callHdr, nil)
931 if err != nil {
932 t.Fatalf("%v.NewStream(_, _) = _, %v, want _, <nil>", ct, err)
933 return
934 }
935 // Wait for server's handler to be initialized
936 select {
937 case <-ready:
938 case <-ctx.Done():
939 t.Fatalf("Client timed out waiting for server handler to be initialized.")
940 }
941 server.mu.Lock()
942 serviceHandler := server.h
943 server.mu.Unlock()
944 var (
945 mu sync.Mutex
946 total int
947 )
948 s.wq.replenish = func(n int) {
949 mu.Lock()
950 total += n
951 mu.Unlock()
952 s.wq.realReplenish(n)
953 }
954 getTotal := func() int {
955 mu.Lock()
956 defer mu.Unlock()
957 return total
958 }
959 done := make(chan struct{})
960 defer close(done)

Callers

nothing calls this directly

Calls 15

DefaultBufferPoolFunction · 0.92
setUpWithOptionsFunction · 0.85
newBufferSliceFunction · 0.85
realReplenishMethod · 0.80
readToMethod · 0.80
stopMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.65
NewStreamMethod · 0.65
FatalfMethod · 0.65
WriteMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected