refactor(drivers): delete GetMemoryFootprint / FlushOptionalCachesAsync (#525)
Both `IDriver` members had no production call site. Their only consumer was `MemoryTracking`, deleted with the driver-tier recycle machinery in #522, and `GetMemoryFootprint`'s doc-comment claimed "polled every 30s by Core" — which had not been true since v3, even before #522 removed the poller. Owner decision on #525 was (a) delete rather than (b) build the process-wide watchdog that would consume them. The driver-side implementations are in git history and were mostly reusable; what was always missing is the trigger, and a member nobody calls is how the misleading doc-comment survived this long. Removed from `IDriver`, all 12 driver implementations, and every test stub — plus the support code that existed only to feed them, which is the part a member-only deletion would have left behind as dead weight: - MTConnect's three per-entry byte-weight constants, its cached `ProbeModelDataItemCount`, and `CountDataItems` — a full device-tree walk run on every cache fill to populate a number with no remaining reader. - OpcUaClient's `_discoveredNodeCount` field and the discovery-pass write to it. - MQTT's `ApproxBytesPerAuthoredTag`. Two behavioural notes, neither a change in what the software does: - `AbCipTemplateCache` now has no production reset path. Its only caller was AB CIP's flush, which itself had no caller — so nothing changes except how visible the fact is. Recorded on the type, along with the correction that its comment's claim about a device `ReinitializeAsync` also flushing it was never true. A UDT redefined on a live controller keeps its stale shape until the driver instance is rebuilt. - MTConnect's `/probe` cache is still dropped, by `InvalidateProbeModel()` on an Agent restart. That is now `internal` rather than `private` so the tests which used the flush purely to empty the cache drive the real path instead — they now cover a case that actually occurs in production. Several unrelated doc comments cited `FlushOptionalCachesAsync` as the canonical CAS example and are repointed to it. Tests: the ones that existed only to assert on the removed members are deleted (3 OpcUaClient, 3 Galaxy, 2 MQTT, 1 MTConnect, 1 AbCip). Worth noting one was vacuous — `FlushOptionalCachesAsync_resets_footprint_counter` asserted a footprint of 0 before the flush and 0 after with no discovery in between, so it would have passed against a flush that did nothing at all. Full suite green except 7 failures verified identical on master before and after (4 AbLegacy integration with the compose profile down, 3 Host.IntegrationTests), checked by name rather than assumed. Docs corrected where they described this as live: `DriverLifecycle.md` (which carried the #525 placeholder), `drivers/AbCip.md`, `drivers/AbLegacy.md`, and `v2/driver-stability.md` — whose "polls this every 30 s" + per-driver `DriverConfig` memory budget were never built as written and are now banner-ed as design intent rather than description. Claude-Session: https://claude.ai/code/session_015p7wGqy3YpZNCpDzTpGMKo
This commit is contained in:
+5
-34
@@ -13,7 +13,6 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
||||
/// <item>Driver.OpcUaClient-009 — WriteAsync timeout maps to BadTimeout, not BadCommunicationError</item>
|
||||
/// <item>Driver.OpcUaClient-010 — OPC UA Byte type maps to UInt16, not Int16</item>
|
||||
/// <item>Driver.OpcUaClient-012 — AutoAcceptCertificates emits a startup warning</item>
|
||||
/// <item>Driver.OpcUaClient-013 — GetMemoryFootprint and FlushOptionalCachesAsync contract</item>
|
||||
/// <item>Driver.OpcUaClient-015 — key pure-logic paths exposed for future test expansion</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
@@ -97,39 +96,11 @@ public sealed class OpcUaClientMediumFindingsRegressionTests
|
||||
}
|
||||
|
||||
// ---- Driver.OpcUaClient-013 ----
|
||||
|
||||
/// <summary>Verifies that GetMemoryFootprint returns zero before discovery.</summary>
|
||||
[Fact]
|
||||
public void GetMemoryFootprint_returns_zero_before_first_discovery()
|
||||
{
|
||||
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-mem-013");
|
||||
// Pre-init: no nodes discovered yet, so footprint is 0.
|
||||
drv.GetMemoryFootprint().ShouldBe(0L);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that FlushOptionalCachesAsync completes without throwing.</summary>
|
||||
[Fact]
|
||||
public async Task FlushOptionalCachesAsync_completes_without_throwing()
|
||||
{
|
||||
// FlushOptionalCachesAsync is a cheap no-op before any discovery. Must not throw.
|
||||
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-flush-013");
|
||||
await Should.NotThrowAsync(async () =>
|
||||
await drv.FlushOptionalCachesAsync(TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that FlushOptionalCachesAsync resets the footprint counter.</summary>
|
||||
[Fact]
|
||||
public async Task FlushOptionalCachesAsync_resets_footprint_counter()
|
||||
{
|
||||
// GetMemoryFootprint uses _discoveredNodeCount * 512. FlushOptionalCachesAsync resets
|
||||
// _discoveredNodeCount to 0, so a subsequent call to GetMemoryFootprint returns 0.
|
||||
// We drive this through a complete Discovery pass against a stub — instead, test the
|
||||
// contract via FlushOptionalCachesAsync clearing a counter we can observe.
|
||||
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-flush2-013");
|
||||
drv.GetMemoryFootprint().ShouldBe(0L, "pre-flush should be 0 (no discovery)");
|
||||
await drv.FlushOptionalCachesAsync(TestContext.Current.CancellationToken);
|
||||
drv.GetMemoryFootprint().ShouldBe(0L, "post-flush should still be 0");
|
||||
}
|
||||
//
|
||||
// Three tests lived here covering GetMemoryFootprint + FlushOptionalCachesAsync. Both members
|
||||
// were deleted from IDriver in Gitea #525 as unconsumed surface, and these went with them. Worth
|
||||
// noting one was vacuous anyway: it asserted a footprint of 0 before the flush and 0 after, with
|
||||
// no discovery in between, so it would have passed against a flush that did nothing at all.
|
||||
|
||||
// ---- Driver.OpcUaClient-015: pure-logic paths ----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user