Skip to content

Commit af82f32

Browse files
RecursiveIntellkjlubick
authored andcommitted
test(proxy): bound TCP buffers in flush deadline regression
Signed-off-by: Josh Stevenson <j.stevenson.cs@gmail.com>
1 parent 60cb443 commit af82f32

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎services/nvpair-proxy/zombie_test.go‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,15 @@ func TestHandleHTTP_BoundsRealSocketFlushes(t *testing.T) {
413413

414414
ln, err := net.Listen("tcp", "127.0.0.1:0")
415415
require.NoError(t, err, "listen")
416-
srv := &http.Server{Handler: http.HandlerFunc(p.soleFacade().handleHTTP)}
416+
// Limit the sender as well: default TCP buffers can absorb the entire
417+
// five-second paced stream without ever blocking a flush.
418+
srv := &http.Server{
419+
Handler: http.HandlerFunc(p.soleFacade().handleHTTP),
420+
ConnContext: func(ctx context.Context, c net.Conn) context.Context {
421+
assert.NoError(t, c.(*net.TCPConn).SetWriteBuffer(4096), "set proxy write buffer")
422+
return ctx
423+
},
424+
}
417425
go func() { _ = srv.Serve(ln) }()
418426
defer srv.Close()
419427

@@ -430,6 +438,9 @@ func TestHandleHTTP_BoundsRealSocketFlushes(t *testing.T) {
430438
_, err = conn.Write([]byte(reqText))
431439
require.NoError(t, err, "write request")
432440

441+
// Bound the receive buffer so a paced stream reaches backpressure within
442+
// the test budget rather than fitting in host-dependent TCP buffers.
443+
require.NoError(t, conn.(*net.TCPConn).SetReadBuffer(1024), "set client read buffer")
433444
// Read the status line only, then stop reading so the proxy's send buffer
434445
// backs up and a Flush blocks.
435446
require.NoError(t, conn.SetReadDeadline(time.Now().Add(5*time.Second)))

0 commit comments

Comments
 (0)