Skip to content

test: wait on conditions, not on the clock (bunker, tui) - #210

Merged
naliyi merged 2 commits into
ohstr:mainfrom
nlkala:propose/test-waits-bunker-tui
Nov 2, 2026
Merged

naliyi merged 2 commits into
ohstr:mainfrom
nlkala:propose/test-waits-bunker-tui

Conversation

@nlkala

@nlkala nlkala commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Branch nlkala:propose/test-waits-bunker-tui on v0.8.0-rc.46 · 2 commits · tests only, independent

Summary

Four upstream tests fail under -race on a loaded machine though nothing is wrong:

  • cli/bunker sendAndAwaitDecision (client_test.go) took 150 ms without a response as "queued":
    a slow handler outlasts it and a granted request reads as pending. It now waits for whichever
    comes first, the response or the request in the queue (10 s ceiling).
  • cli/bunker's overlay tests (TestBunkerBoardOverlayDoesNotBleedThroughToPanelBorders and
    siblings) read the simulation screen's buffer while the app's loop redrew it — a DATA RACE
    report. A screenContents helper copies it inside the loop (QueueUpdate).
  • client/tui TestLoggerSequences hung to the 10 min timeout: two events logged between a
    spinning reader's reads become one row of two (the logger's design), so the tenth row never came.
    It and TestLoggerAggregated now log and read in turn, with no sleeps.
  • cli/relay TestNewServer_WarnsOnIndexMismatch (added after filing, 1ba926d; reported in Three tests flaky under -race on a loaded machine: climatrix index lifecycle, huddle/sfu connect, cli/relay logger race #220):
    a DATA RACE between the test's cleanup, which restores the global zerolog logger
    (command_store_test.go:83), and serve()'s first log line (service.go:480). Stop never joins
    serve(), so the cleanup's order alone couldn't help. The test now waits for that line in its
    buffer (read under the buffer's lock), as service_logger_test already does, so the restore comes
    after serve's read.

Test plan

  • gofmt, build, vet, tidy, golangci-lint v2.13.2: clean
  • go test -short -race ./...: green
  • go test -race -count=5 ./cli/bunker/ ./client/tui/ beside three full -race suites: green
  • go test -short -race -count=1 ./cli/relay/, 10 runs: all ok, no race

🤖 Generated with Claude Code

Three tests failed under -race on a loaded machine though nothing was wrong:

- cli/bunker sendAndAwaitDecision took 150 ms without a response as
  "queued": a slow handler outlasts it. It now waits for whichever comes
  first, the response or the request in the queue (10 s ceiling).
- cli/bunker's overlay tests read the simulation screen's buffer while
  the app's loop redrew it (a DATA RACE): screenContents copies it inside
  the loop (QueueUpdate).
- client/tui TestLoggerSequences hung to the 10 min timeout: two events
  logged between a spinning reader's reads become one row of two (the
  logger's design), so the tenth row never came. It and
  TestLoggerAggregated now log and read in turn, with no sleeps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e restoring the logger

A DATA RACE under -race: the test's cleanup restored the global zerolog logger
(command_store_test.go:83) while the server's serve() goroutine still read it to
log "listening..." (service.go:480). Stop never joins serve(), so the cleanup's
order alone couldn't help. The test now waits for that line in its buffer (read
under the buffer's lock), as service_logger_test already does, so the restore
comes after serve's read.

10 runs of `go test -short -race -count=1 ./cli/relay/`: all ok, no race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@naliyi
naliyi merged commit e9eefa8 into ohstr:main Nov 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants