tests: guarantee cleanup in Modbus cache-reset fixture failure paths #727

Open
opened 2026-10-13 17:27:14 -04:00 by dohertj2 · 1 comment
Owner

Read-only #725 cancellation-warning review found a separate test-owned resource cleanup gap beyond #726’s approved six-fixture scope. Verified at local head eed7cc7d75e4690fb409e0358249489547ace641.

tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Tests/ModbusLifecycleHygieneTests.cs:112 (Reinitialize_clears_lastPublished_and_lastWritten_caches) creates a fake-transport driver and initializes it at line124. Assertions and the subscription/polling path at lines135–142 run before UnsubscribeAsync/ShutdownAsync at143–145. The class is not IDisposable/IAsyncLifetime, and this method has no using/finally cleanup. An initialization or assertion failure bypasses those calls.

Default probing is enabled (src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts/ModbusDriverOptions.cs:39,236); initialization starts the probe CTS/background work (ModbusDriver.cs:354–358). Shutdown/disposal cancels those tokens, disposes the poll engine and fake transport (ModbusDriver.cs:1798–1819). Subscription ownership is additional work on the successful subscribe path. Thus the test owns resources whose cleanup is not registered for failures. This is source evidence of an ownership omission, not a reproduced leak duration, deadlock, production-driver defect or historical CI cause.

Acceptance:

  • Register cleanup before initialization and guarantee shutdown/disposal on initialization, assertion and polling-observation failure paths. Reuse the existing bounded test-only cleanup helper if appropriate; preserve the primary failure and report secondary cleanup failure.
  • Preserve the existing cache population, deadband/write-suppression and post-Shutdown clearing assertions, real subscription path, default probe settings, tokens and deadlines. The normal shutdown inside the oracle must still occur before its cache-clearing assertions; final cleanup must remain safe afterward.
  • Add bounded fake-resource failure coverage for cancellation, request completion and transport disposal. Do not claim a Modbus background probe-task join: the driver discards that Task.
  • Run affected offline tests, review and require final-head hosted CI before merge/closure. No production edits or live calls.

Related #725 and #726. #726’s empty-bitmap test cleanup is already independently reviewed and locally committed; this cache-reset fixture is not in that bounded implementation. The warning audit sampled19 sites, not every lifecycle test. Exact-test-name state=all duplicate search returned no issue. Evidence: work/lmx725-cancellation-warning-audit.md plus parent source inspection. No implementation has been performed for this follow-up; it needs its own bounded design approval.

Read-only #725 cancellation-warning review found a separate test-owned resource cleanup gap beyond #726’s approved six-fixture scope. Verified at local head `eed7cc7d75e4690fb409e0358249489547ace641`. `tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Tests/ModbusLifecycleHygieneTests.cs:112` (`Reinitialize_clears_lastPublished_and_lastWritten_caches`) creates a fake-transport driver and initializes it at line124. Assertions and the subscription/polling path at lines135–142 run before `UnsubscribeAsync`/`ShutdownAsync` at143–145. The class is not IDisposable/IAsyncLifetime, and this method has no using/finally cleanup. An initialization or assertion failure bypasses those calls. Default probing is enabled (`src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Modbus.Contracts/ModbusDriverOptions.cs:39,236`); initialization starts the probe CTS/background work (`ModbusDriver.cs:354–358`). Shutdown/disposal cancels those tokens, disposes the poll engine and fake transport (`ModbusDriver.cs:1798–1819`). Subscription ownership is additional work on the successful subscribe path. Thus the test owns resources whose cleanup is not registered for failures. This is source evidence of an ownership omission, not a reproduced leak duration, deadlock, production-driver defect or historical CI cause. Acceptance: - Register cleanup before initialization and guarantee shutdown/disposal on initialization, assertion and polling-observation failure paths. Reuse the existing bounded test-only cleanup helper if appropriate; preserve the primary failure and report secondary cleanup failure. - Preserve the existing cache population, deadband/write-suppression and post-Shutdown clearing assertions, real subscription path, default probe settings, tokens and deadlines. The normal shutdown inside the oracle must still occur before its cache-clearing assertions; final cleanup must remain safe afterward. - Add bounded fake-resource failure coverage for cancellation, request completion and transport disposal. Do not claim a Modbus background probe-task join: the driver discards that Task. - Run affected offline tests, review and require final-head hosted CI before merge/closure. No production edits or live calls. Related #725 and #726. #726’s empty-bitmap test cleanup is already independently reviewed and locally committed; this cache-reset fixture is not in that bounded implementation. The warning audit sampled19 sites, not every lifecycle test. Exact-test-name state=all duplicate search returned no issue. Evidence: `work/lmx725-cancellation-warning-audit.md` plus parent source inspection. No implementation has been performed for this follow-up; it needs its own bounded design approval.
Author
Owner

The bounded source check found a separate production token-acquisition race window, now tracked in#729. Modbus’s scheduling token is evaluated immediately while the worker lambda retrieves its token later from mutable CTS fields. Local BCL/docs support a post-start-check teardown/replacement interleaving; execution impact remains unmeasured. No#728/historical CI cause is inferred. #727 remains strictly the approved-question test-only cleanup scope; do not blend production token/join changes into it. No source edits or test execution were performed for the new finding. Existing#726 fake-resource evidence remains scenario-specific and does not establish an authoritative probe-task join.

The bounded source check found a separate production token-acquisition race window, now tracked in#729. Modbus’s scheduling token is evaluated immediately while the worker lambda retrieves its token later from mutable CTS fields. Local BCL/docs support a post-start-check teardown/replacement interleaving; execution impact remains unmeasured. No#728/historical CI cause is inferred. #727 remains strictly the approved-question test-only cleanup scope; do not blend production token/join changes into it. No source edits or test execution were performed for the new finding. Existing#726 fake-resource evidence remains scenario-specific and does not establish an authoritative probe-task join.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#727