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

Function waitForGoAwayTooManyPings

internal/transport/keepalive_test.go:844–860  ·  view source on GitHub ↗

waitForGoAwayTooManyPings waits for client to receive a GoAwayTooManyPings from server. It also asserts that stream creation fails after receiving a GoAway.

(client *http2Client)

Source from the content-addressed store, hash-verified

842// from server. It also asserts that stream creation fails after receiving a
843// GoAway.
844func waitForGoAwayTooManyPings(client *http2Client) error {
845 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
846 defer cancel()
847 select {
848 case <-client.GoAway():
849 if reason, _ := client.GetGoAwayReason(); reason != GoAwayTooManyPings {
850 return fmt.Errorf("goAwayReason is %v, want %v", reason, GoAwayTooManyPings)
851 }
852 case <-ctx.Done():
853 return fmt.Errorf("test timed out before getting GoAway with reason:GoAwayTooManyPings from server")
854 }
855
856 if _, err := client.NewStream(ctx, &CallHdr{}, nil); err == nil {
857 return fmt.Errorf("stream creation succeeded after receiving a GoAway from the server")
858 }
859 return nil
860}

Calls 5

GoAwayMethod · 0.65
GetGoAwayReasonMethod · 0.65
ErrorfMethod · 0.65
NewStreamMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected