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

Method TestCloseSetsConnectionDeadlines

internal/transport/transport_test.go:3334–3361  ·  view source on GitHub ↗

Tests that connection read and write deadlines are set as expected during Close().

(t *testing.T)

Source from the content-addressed store, hash-verified

3332// Tests that connection read and write deadlines are set as expected during
3333// Close().
3334func (s) TestCloseSetsConnectionDeadlines(t *testing.T) {
3335 dialer := func(_ context.Context, addr string) (net.Conn, error) {
3336 conn, err := net.Dial("tcp", addr)
3337 if err != nil {
3338 return nil, err
3339 }
3340 return &deadlineTestConn{Conn: conn}, nil
3341 }
3342 co := ConnectOptions{
3343 Dialer: dialer,
3344 BufferPool: mem.DefaultBufferPool(),
3345 }
3346 server, client, cancel := setUpWithOptions(t, 0, &ServerConfig{BufferPool: mem.DefaultBufferPool()}, normal, co)
3347 defer cancel()
3348 defer server.stop()
3349 dConn := client.conn.(*deadlineTestConn)
3350 // Set both to false before invoking Close() in case some other code set a
3351 // deadline above.
3352 dConn.observedReadDeadline.Store(false)
3353 dConn.observedWriteDeadline.Store(false)
3354 client.Close(fmt.Errorf("closed manually by test"))
3355 if !dConn.observedReadDeadline.Load() {
3356 t.Errorf("Connection read deadline was never set")
3357 }
3358 if !dConn.observedWriteDeadline.Load() {
3359 t.Errorf("Connection write deadline was never set")
3360 }
3361}
3362
3363// TestReadHeaderMultipleBuffers tests the stream when the gRPC headers are
3364// split across multiple buffers. It verifies that the reporting of the

Callers

nothing calls this directly

Calls 7

DefaultBufferPoolFunction · 0.92
setUpWithOptionsFunction · 0.85
stopMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.65
DialMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected