Skip to content

test(drivers): synchronize control v2 Modbus test fake - #787

Merged
frahlg merged 1 commit into
masterfrom
agent/fix-control-v2-test-race
Aug 4, 2026
Merged

frahlg merged 1 commit into
masterfrom
agent/fix-control-v2-test-race

Conversation

@frahlg

@frahlg frahlg commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Protect the controlV2Modbus test double with an RWMutex.
  • Route register, write-count, and write-error setup/assertions through locked accessors.
  • Keep the fix confined to go/internal/drivers/control_v2_test.go; no changeset is needed for a test-only change.

Root cause

TestControlV2RegistryExpiresLeaseIntoDefault read the fake Modbus register map directly while the registry run loop could write it during lease expiry. The race is in the test harness, not production code: the registry serializes each driver's lifecycle, poll, command, and default work in one run loop, and the production Modbus capability serializes its calls independently.

Validation

  • go test -race ./internal/drivers -run '^TestControlV2RegistryExpiresLeaseIntoDefault$' -count=5
  • go test -race ./internal/drivers -run 'ControlV2' -count=3
  • go test -race ./internal/drivers -count=1
  • make verify
  • make verify-all via the pre-push hook, including Linux arm64/amd64 and Windows amd64 builds
  • Independent read-only review: approved with no blockers

The PR remains draft until normal repository review is complete.

@frahlg frahlg added the no-changeset PR intentionally exempt from the changeset requirement (dev tooling / non-shipping) label Aug 4, 2026 — with ChatGPT Codex Connector
@frahlg
frahlg force-pushed the agent/fix-control-v2-test-race branch from 1aa6ec2 to 6dc2e86 Compare August 4, 2026 09:09
@frahlg
frahlg marked this pull request as ready for review August 4, 2026 09:13
@frahlg
frahlg merged commit a520ebb into master Aug 4, 2026
13 checks passed
@frahlg
frahlg deleted the agent/fix-control-v2-test-race branch August 7, 2026 08:14
frahlg added a commit that referenced this pull request Oct 17, 2026
* ci: run the Go race detector on the control-loop packages

CI runs go test without -race. Agents report "race tests pass" from
local runs, and two races still merged: #787 and #789 fixed test fakes
that raced after landing. On their parent commits (ee416d1, 5d5f810)
this check fails with WARNING: DATA RACE.

.github/scripts/race.sh runs -race on the 16 package trees that share
state with the control loop. The same command runs locally and in the
new race job, which the required go test + vet check now waits for.
All of them pass on master today.

* ci: skip the wall-clock retention budget test under -race

The race detector slows code 5-10x, so the 3-second retention budget in
TestForecastRetentionLargeOverflowWithinScoringBudget failed on CI with
no data race. The plain test job still enforces the budget.

* ci: exercise race script edits in Core checks

Signed-off-by: Fredrik Ahlgren <[email protected]>

---------

Signed-off-by: Fredrik Ahlgren <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changeset PR intentionally exempt from the changeset requirement (dev tooling / non-shipping)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant