Repository navigation
test: wait on conditions, not on the clock (bunker, tui) - #210
Merged
Merged
Conversation
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>
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch
nlkala:propose/test-waits-bunker-tuionv0.8.0-rc.46· 2 commits · tests only, independentSummary
Four upstream tests fail under
-raceon a loaded machine though nothing is wrong:cli/bunkersendAndAwaitDecision(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 (TestBunkerBoardOverlayDoesNotBleedThroughToPanelBordersandsiblings) read the simulation screen's buffer while the app's loop redrew it — a
DATA RACEreport. A
screenContentshelper copies it inside the loop (QueueUpdate).client/tuiTestLoggerSequenceshung to the 10 min timeout: two events logged between aspinning reader's reads become one row of two (the logger's design), so the tenth row never came.
It and
TestLoggerAggregatednow log and read in turn, with no sleeps.cli/relayTestNewServer_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 RACEbetween the test's cleanup, which restores the global zerolog logger(
command_store_test.go:83), andserve()'s first log line (service.go:480).Stopnever joinsserve(), so the cleanup's order alone couldn't help. The test now waits for that line in itsbuffer (read under the buffer's lock), as
service_logger_testalready does, so the restore comesafter serve's read.
Test plan
go test -short -race ./...: greengo test -race -count=5 ./cli/bunker/ ./client/tui/beside three full-racesuites: greengo test -short -race -count=1 ./cli/relay/, 10 runs: all ok, no race🤖 Generated with Claude Code