Repository navigation
test(ocpp): stop test chargers after the server (#1712) - #1717
Merged
Merged
Conversation
Core probes each charger it accepts (GetConfiguration, then a
TriggerMessage identity probe). Several tests stopped their charge point
before the server, so a probe could arrive while the charger closed.
ocpp-go v0.19.0's ws.Client.Write checks the connection and then sends
without its lock, so the answer could send on the closed queue and panic
("send on closed channel", seen in run 39045946853).
stopAfterServer stops the server first at cleanup; Server.Stop is
idempotent. Only test code changes; Core uses the ocpp-go server, and
the client runs only in tests and cmd/sim-ocpp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 18, 2026
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.
Part of #1712.
Problem
go/internal/ocpppanicked once in CI withsend on closed channel(run 39045946853, on #1703, which does not touch OCPP). The stack ends in the test charge point:ocpp-go@v0.19.0/ws.(*Client).Write←ocppj.(*Client).SendError←chargePoint.notSupportedError←readPump. The test running wasTestPerChargerCredentialOverTheWire. Its last log line before the panic is Core's capability probe gettingNotSupportedfromgarage-impostor.Core probes each charger it accepts:
GetConfiguration, then aTriggerMessageidentity probe. Several tests stop their charge point before the server, because the server's cleanup ordeferwas registered first and runs last. A probe can then reach the charger while it closes.ws.Client.WritechecksIsConnected()and then sends onoutQueuewithout its lock, whilecleanup()closesoutQueue. An answer that passes the check just before the close panics.The
ocpp-goclient runs only in tests andcmd/sim-ocpp; Core uses its server. There is no newerocpp-gorelease than v0.19.0.Change
stopAfterServer(t, srv, stop)(inserver_test.go) stops the server first at cleanup, then the charger.Server.Stopis idempotent (stopOnce) and stops the identity probes before it closes connections. It replaces the charger cleanup where the charger used to stop first:auth_test.go(TestPerChargerCredentialOverTheWire)identity_test.go(TestBootNotificationTakesEitherSerialField)server_test.go(three tests that useddefer cp.Stop()afterdefer srv.Stop())control_test.goconnectCharger,control_v201_test.goconnectStationV201,charging_needs_test.goconnectStationForNeedsTests that stop the server with
deferalready stopped it before theirt.Cleanupchargers, socapabilities_test.goand most ofcontrol_test.gowere safe and do not change.Not covered
TestCapabilityProbeMarkerClearedOnDisconnect, the socket and disconnect tests), keep the library's narrow window. Closing it needs a fix inocpp-go.TestForecastRetentionLargeOverflowWithinScoringBudgetis already skipped in the race job by.github/scripts/race.shand still runs in the plain job.TestTheBoxOpensAnExchangeBesideItsUplinklives inappuplink/exchange_test.go, which fix(cloud): remove retired relay code and DNS dependency #1691 changes.TestAPlugInReachesAStreamingPhoneAsAPlanlives incmd/ftw/app_link_plan_push_test.go, which fix(ev): preserve confirmed power history and verify charging recovery #1675 changes and already makes wait for the published revision. Both open PRs have right of way.Evidence
TestPerChargerCredentialOverTheWirewith-race(four parallel runs of 500,GOMAXPROCS=2); the window is a few instructions wide. The fix is by construction: no probe can be sent once the server has stopped.go test -race -count=20 ./internal/ocpp/: ok (57.8 s).go vet ./internal/ocpp/: ok.make verifywas not run locally; CI runs the full suite.Test-only change, so it carries the
no-changesetlabel.🤖 Generated with Claude Code