test(run): add race detector and edge case tests#179
Conversation
📦 Previous Review (superseded by newer review)Claude finished @dpup's task in 2m 12s —— View job Code Review — PR #179
Overall this is good work — the race detector integration, mock infrastructure, and most of the tests are solid. One issue stands out: the race fix in Issues1. Incomplete race fix —
|
📦 Previous Review (superseded by newer review)Claude finished @dpup's task in 4m 44s —— View job Code Review — PR #179
The follow-up commit ( What was fixed
Stale comment — updated to accurately reflect the completed fix and its scope. The lock ordering is also correct: by moving Remaining pre-existing issues (not introduced by this PR)1. Double lock in
|
📦 Previous Review (superseded by newer review)Claude finished @dpup's task in 4m 23s —— View job Code Review — PR #179
All three issues from the previous reviews are resolved. The latest commit ( What was fixed in
|
- Enable -race flag in Makefile test-unit and coverage targets - Add 28 edge case tests: firewall failures, cleanup error paths, concurrent access, privileged mode, log capture, monitor exit - Fix pre-existing data race in Stop() by using SetStateWithTime() instead of direct field writes under wrong mutex - Add flexibleRuntime test helper for configurable mock testing - Update CLAUDE.md and CONTRIBUTING.md to reference make targets
Add SetStateFailedAt to atomically set state, error, and timestamp in a single lock acquisition. Use it in monitorContainerExit (fixes double lock) and both Start/StartAttached firewall failure paths (fixes stale StateRunning/StateStarting on failure).
Address remaining review feedback from PR #179: - SaveMetadata: snapshot stateMu-guarded fields under lock before disk write, fixing race between Stop() and monitorContainerExit() - Destroy: use r.GetState() instead of direct r.State read - StartContainer failure: use SetStateFailedAt for consistency with firewall failure path - CLI layer: migrate all r.State reads to r.GetState() across attach, clean, destroy, exec, list, resolve, status, stop, and wt commands - Tests: add StateFailed assertions to firewall failure tests, fix flexibleRuntime field naming consistency (containerLogsAllFn)
6ad6b36 to
4a87b72
Compare
|
Picked up this PR, rebased onto main, and addressed all review feedback in commit Review items addressed:
All tests pass with |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Summary
Closes #82 — adds race detector to CI/Makefile and comprehensive edge case tests.
make test-unitandmake coveragenow run with-raceflag. CI already had it; this aligns local dev workflow.Stop()— was writingr.Stateunderm.mu(manager mutex) whilemonitorContainerExitreads viar.stateMu(run mutex). Fixed to user.SetStateWithTime()consistently.flexibleRuntimemock with configurable function fields for targeted error-path testing.Test plan
go test -race ./internal/run/go test -race ./...passesgo vet ./...cleangolangci-lint runcleanmake test-unituses-racemake coverageuses-race -covermode=atomic🤖 Generated with Claude Code