test(brokeripc): pin the broker client window and document pipe headroom limits
- commit
- 2d01baf62ae0705be9cff095189b92e02fff36a1
- author
- brice · · 2026-10-08 10:40 UTC
- parent
- e8bf3a5
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +14 -3
M internal/adapters/brokeripc/pipe_test.go +14 -3
| @@ -112,9 +112,11 @@ func TestStreamPipeCloseWithPreservesQueuedDataOnOrderlyClose(t *testing.T) { | |||
| 112 | 112 | // TestStreamPipeHoldsAFullOutputWindow pins the client pipe headroom for the | |
| 113 | 113 | // session output window. A client claims protocol.MaxOutputWindow unacked | |
| 114 | 114 | // Output frames; with a terminal that is not draining, all of them may sit in | |
| 115 | - | // this pipe at once. Overflow fails the whole stream (ErrStreamBackpressure), | |
| 116 | - | // so the default bounds must hold that window of worst realistic frames: a | |
| 117 | - | // near-full repaint of a 500x140 terminal is about 70 KB, i.e. two chunks. | |
| 115 | + | // this pipe at once, and overflow fails the whole stream | |
| 116 | + | // (ErrStreamBackpressure). The frame size is a typical text repaint: a | |
| 117 | + | // near-full page of a 500x140 terminal measured about 70 KB. Uncompressed diff | |
| 118 | + | // frames with per-cell truecolor SGR can be far larger (estimated near 1 MB at | |
| 119 | + | // 300x80), and eight of those can still overflow the default 4 MiB bound. | |
| 118 | 120 | func TestStreamPipeHoldsAFullOutputWindow(t *testing.T) { | |
| 119 | 121 | const frameBytes = 72 << 10 | |
| 120 | 122 | chunk := int(brokerwire.MaxStreamChunkBytes) | |
| @@ -128,3 +130,12 @@ func TestStreamPipeHoldsAFullOutputWindow(t *testing.T) { | |||
| 128 | 130 | } | |
| 129 | 131 | } | |
| 130 | 132 | } | |
| 133 | + | ||
| 134 | + | // TestClientStreamPrefersTheFullOutputWindow pins what a real broker-routed | |
| 135 | + | // attachment reports: its carriage is a reliable stream, not a datagram link, | |
| 136 | + | // so the client claims the full output window and frames pipeline. | |
| 137 | + | func TestClientStreamPrefersTheFullOutputWindow(t *testing.T) { | |
| 138 | + | st, err := newClientStream(&client{}, 1) | |
| 139 | + | require.NoError(t, err) | |
| 140 | + | require.Equal(t, uint8(protocol.MaxOutputWindow), st.Capabilities().PreferredOutputWindow) | |
| 141 | + | } | |
| @@ -112,9 +112,11 @@ func TestStreamPipeCloseWithPreservesQueuedDataOnOrderlyClose(t *testing.T) { | |||||
| 112 | // TestStreamPipeHoldsAFullOutputWindow pins the client pipe headroom for the | 112 | // TestStreamPipeHoldsAFullOutputWindow pins the client pipe headroom for the | ||
| 113 | // session output window. A client claims protocol.MaxOutputWindow unacked | 113 | // session output window. A client claims protocol.MaxOutputWindow unacked | ||
| 114 | // Output frames; with a terminal that is not draining, all of them may sit in | 114 | // Output frames; with a terminal that is not draining, all of them may sit in | ||
| 115 | - | // this pipe at once. Overflow fails the whole stream (ErrStreamBackpressure), | 115 | + | // this pipe at once, and overflow fails the whole stream |
| 116 | - | // so the default bounds must hold that window of worst realistic frames: a | 116 | + | // (ErrStreamBackpressure). The frame size is a typical text repaint: a |
| 117 | - | // near-full repaint of a 500x140 terminal is about 70 KB, i.e. two chunks. | 117 | + | // near-full page of a 500x140 terminal measured about 70 KB. Uncompressed diff |
| 118 | + | // frames with per-cell truecolor SGR can be far larger (estimated near 1 MB at | |||
| 119 | + | // 300x80), and eight of those can still overflow the default 4 MiB bound. | |||
| 118 | func TestStreamPipeHoldsAFullOutputWindow(t *testing.T) { | 120 | func TestStreamPipeHoldsAFullOutputWindow(t *testing.T) { | ||
| 119 | const frameBytes = 72 << 10 | 121 | const frameBytes = 72 << 10 | ||
| 120 | chunk := int(brokerwire.MaxStreamChunkBytes) | 122 | chunk := int(brokerwire.MaxStreamChunkBytes) | ||
| @@ -128,3 +130,12 @@ func TestStreamPipeHoldsAFullOutputWindow(t *testing.T) { | |||||
| 128 | } | 130 | } | ||
| 129 | } | 131 | } | ||
| 130 | } | 132 | } | ||
| 133 | + | ||||
| 134 | + | // TestClientStreamPrefersTheFullOutputWindow pins what a real broker-routed | |||
| 135 | + | // attachment reports: its carriage is a reliable stream, not a datagram link, | |||
| 136 | + | // so the client claims the full output window and frames pipeline. | |||
| 137 | + | func TestClientStreamPrefersTheFullOutputWindow(t *testing.T) { | |||
| 138 | + | st, err := newClientStream(&client{}, 1) | |||
| 139 | + | require.NoError(t, err) | |||
| 140 | + | require.Equal(t, uint8(protocol.MaxOutputWindow), st.Capabilities().PreferredOutputWindow) | |||
| 141 | + | } | |||