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

Function testClientConnCloseAfterGoAwayWithActiveStream

test/goaway_test.go:178–203  ·  view source on GitHub ↗
(t *testing.T, e env)

Source from the content-addressed store, hash-verified

176}
177
178func testClientConnCloseAfterGoAwayWithActiveStream(t *testing.T, e env) {
179 te := newTest(t, e)
180 te.startServer(&testServer{security: e.security})
181 defer te.tearDown()
182 cc := te.clientConn()
183 tc := testgrpc.NewTestServiceClient(cc)
184
185 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
186 defer cancel()
187 if _, err := tc.FullDuplexCall(ctx); err != nil {
188 t.Fatalf("%v.FullDuplexCall(_) = _, %v, want _, <nil>", tc, err)
189 }
190 done := make(chan struct{})
191 go func() {
192 te.srv.GracefulStop()
193 close(done)
194 }()
195 time.Sleep(50 * time.Millisecond)
196 cc.Close()
197 timeout := time.NewTimer(time.Second)
198 select {
199 case <-done:
200 case <-timeout.C:
201 t.Fatalf("Test timed-out.")
202 }
203}
204
205func (s) TestServerGoAway(t *testing.T) {
206 for _, e := range listTestEnv() {

Calls 9

FullDuplexCallMethod · 0.95
NewTimerMethod · 0.80
newTestFunction · 0.70
FatalfMethod · 0.65
GracefulStopMethod · 0.65
CloseMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected