detached e8bf3a5

test(brokeripc): pin client pipe headroom for a full output window

commit
e8bf3a5f978e34ebe4f009f1da39db77b48c6411
author
brice · · 2026-10-08 10:38 UTC
parent
4fda349
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +25 -2
M internal/adapters/brokeripc/pipe_test.go +22 -0
@@ -6,6 +6,8 @@ import (
66 "io"
77 "testing"
88
9+ "github.com/bnema/vev/internal/adapters/brokerwire"
10+ "github.com/bnema/vev/internal/protocol"
911 "github.com/stretchr/testify/require"
1012 )
1113
@@ -106,3 +108,23 @@ func TestStreamPipeCloseWithPreservesQueuedDataOnOrderlyClose(t *testing.T) {
106108 })
107109 }
108110 }
111+
112+// TestStreamPipeHoldsAFullOutputWindow pins the client pipe headroom for the
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
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.
118+func TestStreamPipeHoldsAFullOutputWindow(t *testing.T) {
119+ const frameBytes = 72 << 10
120+ chunk := int(brokerwire.MaxStreamChunkBytes)
121+ p := newStreamPipe(0, 0, func([]byte) error { return nil })
122+ payload := bytes.Repeat([]byte{'x'}, frameBytes)
123+ for frame := range protocol.MaxOutputWindow {
124+ for data := payload; len(data) > 0; {
125+ n := min(len(data), chunk)
126+ require.NoError(t, p.deliver(data[:n]), "frame %d overflowed the client pipe", frame)
127+ data = data[n:]
128+ }
129+ }
130+}
@@ -6,6 +6,8 @@ import (
6 "io"6 "io"
7 "testing"7 "testing"
8 8
9+ "github.com/bnema/vev/internal/adapters/brokerwire"
10+ "github.com/bnema/vev/internal/protocol"
9 "github.com/stretchr/testify/require"11 "github.com/stretchr/testify/require"
10 )12 )
11 13
@@ -106,3 +108,23 @@ func TestStreamPipeCloseWithPreservesQueuedDataOnOrderlyClose(t *testing.T) {
106 })108 })
107 }109 }
108 }110 }
111+
112+// TestStreamPipeHoldsAFullOutputWindow pins the client pipe headroom for the
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
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.
118+func TestStreamPipeHoldsAFullOutputWindow(t *testing.T) {
119+ const frameBytes = 72 << 10
120+ chunk := int(brokerwire.MaxStreamChunkBytes)
121+ p := newStreamPipe(0, 0, func([]byte) error { return nil })
122+ payload := bytes.Repeat([]byte{'x'}, frameBytes)
123+ for frame := range protocol.MaxOutputWindow {
124+ for data := payload; len(data) > 0; {
125+ n := min(len(data), chunk)
126+ require.NoError(t, p.deliver(data[:n]), "frame %d overflowed the client pipe", frame)
127+ data = data[n:]
128+ }
129+ }
130+}
M internal/usecase/client/runtime_primitives_test.go +3 -2
@@ -35,8 +35,9 @@ func TestRequestedOutputWindow(t *testing.T) {
3535 }
3636 }
3737
38-// TestHelloRequestsPipelinedOutput pins the window a real attachment Hello
39-// asks for. A window of one would make every remote frame wait a round trip.
38+// TestHelloRequestsPipelinedOutput pins the fallback window an attachment
39+// Hello claims when its carriage states no preference. A window of one would
40+// make every remote frame wait a round trip.
4041 func TestHelloRequestsPipelinedOutput(t *testing.T) {
4142 worker, err := newSessionAttachmentWorker(sessionAttachmentConfig{Request: sessionTestRequest(false), SessionEnvironment: SessionEnvironment{Provenance: SessionEnvironmentRemote}})
4243 require.NoError(t, err)
@@ -35,8 +35,9 @@ func TestRequestedOutputWindow(t *testing.T) {
35 }35 }
36 }36 }
37 37
38-// TestHelloRequestsPipelinedOutput pins the window a real attachment Hello38+// TestHelloRequestsPipelinedOutput pins the fallback window an attachment
39-// asks for. A window of one would make every remote frame wait a round trip.39+// Hello claims when its carriage states no preference. A window of one would
40+// make every remote frame wait a round trip.
40 func TestHelloRequestsPipelinedOutput(t *testing.T) {41 func TestHelloRequestsPipelinedOutput(t *testing.T) {
41 worker, err := newSessionAttachmentWorker(sessionAttachmentConfig{Request: sessionTestRequest(false), SessionEnvironment: SessionEnvironment{Provenance: SessionEnvironmentRemote}})42 worker, err := newSessionAttachmentWorker(sessionAttachmentConfig{Request: sessionTestRequest(false), SessionEnvironment: SessionEnvironment{Provenance: SessionEnvironmentRemote}})
42 require.NoError(t, err)43 require.NoError(t, err)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close