detached b906d90

test(daemon): cover coordinator send lock order

commit
b906d90bc4c0af74903c7e3a13d8dcd530328441
author
brice · · 2026-07-11 19:01 UTC
parent
91e8bae
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +54 -0
M internal/usecase/daemon/render_coordinator_test.go +54 -0
@@ -313,6 +313,60 @@ func TestRenderCoordinatorUrgentDeadlineCannotBeExtended(t *testing.T) {
313313
314314 // --- ACK gating ----------------------------------------------------------------
315315
316+func TestRenderCoordinatorAckReadinessReentersWithoutBlockingResize(t *testing.T) {
317+ owner := &attachedClient{}
318+ wakes := make(chan renderWake, 1)
319+ ackEntered := make(chan struct{})
320+ resizeDone := make(chan uint64, 1)
321+ fireDone := make(chan struct{})
322+
323+ var rc *renderCoordinator
324+ rc = newRenderCoordinator(renderCoordinatorOptions{
325+ ackReady: func() bool {
326+ close(ackEntered)
327+ // The readiness probe models the output send path reading coordinator
328+ // metadata after sendMu is held. It must never run under c.mu.
329+ _ = rc.resizeSnapshot()
330+ return true
331+ },
332+ wake: func(w renderWake) { wakes <- w },
333+ })
334+ rc.attach(owner)
335+ rc.invalidate(renderInvalidation{class: invalidateOutput, producer: "render.go"})
336+
337+ go func() {
338+ rc.fire(1, false, true)
339+ close(fireDone)
340+ }()
341+ for range 4096 {
342+ select {
343+ case <-ackEntered:
344+ goto resize
345+ default:
346+ runtime.Gosched()
347+ }
348+ }
349+ t.Fatal("ack readiness was not evaluated")
350+
351+resize:
352+ go func() { resizeDone <- rc.recordResizeRequest(domain.Size{Cols: 120, Rows: 40}, owner) }()
353+ for range 4096 {
354+ select {
355+ case epoch := <-resizeDone:
356+ require.Equal(t, uint64(1), epoch)
357+ select {
358+ case <-fireDone:
359+ case <-wakes:
360+ t.Fatal("fire did not return after wake")
361+ }
362+ return
363+ default:
364+ runtime.Gosched()
365+ }
366+ }
367+ t.Fatal("ack readiness re-entry blocked resize metadata")
368+}
369+
316370 func TestRenderCoordinatorAckDoesNotBypassAnUnexpiredDeadline(t *testing.T) {
317371 h := newCoordinatorHarness(t)
318372 h.rc.invalidate(renderInvalidation{class: invalidateOutput, producer: "render.go"})
@@ -313,6 +313,60 @@ func TestRenderCoordinatorUrgentDeadlineCannotBeExtended(t *testing.T) {
313 313
314 // --- ACK gating ----------------------------------------------------------------314 // --- ACK gating ----------------------------------------------------------------
315 315
316+func TestRenderCoordinatorAckReadinessReentersWithoutBlockingResize(t *testing.T) {
317+ owner := &attachedClient{}
318+ wakes := make(chan renderWake, 1)
319+ ackEntered := make(chan struct{})
320+ resizeDone := make(chan uint64, 1)
321+ fireDone := make(chan struct{})
322+
323+ var rc *renderCoordinator
324+ rc = newRenderCoordinator(renderCoordinatorOptions{
325+ ackReady: func() bool {
326+ close(ackEntered)
327+ // The readiness probe models the output send path reading coordinator
328+ // metadata after sendMu is held. It must never run under c.mu.
329+ _ = rc.resizeSnapshot()
330+ return true
331+ },
332+ wake: func(w renderWake) { wakes <- w },
333+ })
334+ rc.attach(owner)
335+ rc.invalidate(renderInvalidation{class: invalidateOutput, producer: "render.go"})
336+
337+ go func() {
338+ rc.fire(1, false, true)
339+ close(fireDone)
340+ }()
341+ for range 4096 {
342+ select {
343+ case <-ackEntered:
344+ goto resize
345+ default:
346+ runtime.Gosched()
347+ }
348+ }
349+ t.Fatal("ack readiness was not evaluated")
350+
351+resize:
352+ go func() { resizeDone <- rc.recordResizeRequest(domain.Size{Cols: 120, Rows: 40}, owner) }()
353+ for range 4096 {
354+ select {
355+ case epoch := <-resizeDone:
356+ require.Equal(t, uint64(1), epoch)
357+ select {
358+ case <-fireDone:
359+ case <-wakes:
360+ t.Fatal("fire did not return after wake")
361+ }
362+ return
363+ default:
364+ runtime.Gosched()
365+ }
366+ }
367+ t.Fatal("ack readiness re-entry blocked resize metadata")
368+}
369+
316 func TestRenderCoordinatorAckDoesNotBypassAnUnexpiredDeadline(t *testing.T) {370 func TestRenderCoordinatorAckDoesNotBypassAnUnexpiredDeadline(t *testing.T) {
317 h := newCoordinatorHarness(t)371 h := newCoordinatorHarness(t)
318 h.rc.invalidate(renderInvalidation{class: invalidateOutput, producer: "render.go"})372 h.rc.invalidate(renderInvalidation{class: invalidateOutput, producer: "render.go"})

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