Tests that connection read and write deadlines are set as expected during Close().
(t *testing.T)
| 3332 | // Tests that connection read and write deadlines are set as expected during |
| 3333 | // Close(). |
| 3334 | func (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 |
nothing calls this directly
no test coverage detected