Skip to content

review: take the workload manager tests off the clock - #139

Merged
CMGS merged 2 commits into
masterfrom
review/test-clock
Sep 9, 2026
Merged

CMGS merged 2 commits into
masterfrom
review/test-clock

Conversation

@CMGS

@CMGS CMGS commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What

  • manager/workload/manager_test.go: TestRun runs under testing/synctest, so the manager's 30 s run timeout elapses on the fake clock. PATH is emptied for the test so the journal forwarder's journalctl lookup fails before any subprocess starts (a real subprocess read is not durably blocked and would stall the fake clock on a host that has journalctl), and the test drains two forwarder retry intervals after Run returns because synctest fails on blocked goroutines once the root goroutine exits.
  • manager/workload/log_test.go: TestLogBroadcaster serves on an ephemeral loopback port and waits for the subscriber to attach and detach through the broadcaster's own registry instead of sleeping around the broadcast.

Why

These were the last wall-clock waits in the agent tests. They cost 34 s per run and passed or failed on machine load rather than on behaviour.

Evidence

go test -race -count=1 -run 'TestRun$|TestLogBroadcaster$' ./manager/workload/
ok      github.com/projecteru2/agent/manager/workload   0.323s   (was 34.4 s)
go test -race -count=100 -run 'TestRun$' ./manager/workload/
ok      github.com/projecteru2/agent/manager/workload   (3.1 s wall clock)

Gate on this branch: build, vet, full tests, make lint, make fmt-check and asl on both GOOS green; comment delta +0 −0.

CMGS added 2 commits September 9, 2026 08:58
TestRun runs under synctest so the 30 s manager timeout elapses on the
fake clock; TestLogBroadcaster serves on an ephemeral port and waits for
the subscriber to attach and detach instead of sleeping. The two tests
together: 34 s -> 0.3 s.
The journal forwarder execs journalctl, and a real subprocess read is
not durably blocked: on a host that has journalctl the bubble never
idles and the fake clock never advances. An empty PATH fails the
lookup before any subprocess starts, so the forwarder retries on the
fake clock on every platform. The forwarder is mid-sleep when the run
deadline fires, and synctest panics on blocked goroutines once the
root goroutine exits, so the test drains two retry intervals after Run
returns (-count=100 fails without the drain).
@CMGS
CMGS merged commit 5353f30 into master Sep 9, 2026
3 checks passed
@CMGS
CMGS deleted the review/test-clock branch September 9, 2026 08:16
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.

1 participant