Auto: ablegacy-10 — diagnostic counters as tags

Closes #253
This commit is contained in:
Joseph Doherty
2026-04-26 03:50:47 -04:00
parent 14876ea210
commit 42472b5549
10 changed files with 1000 additions and 5 deletions

View File

@@ -29,6 +29,16 @@
.PARAMETER BridgeNodeId
NodeId at which the server publishes the Address.
.PARAMETER DiagnosticsRequestCountNodeId
Optional NodeId for the synthetic _Diagnostics/<host>/RequestCount variable
emitted by AB Legacy discovery (PR ablegacy-10 / #253). When supplied, the
script runs the DiagnosticsRequestCount assertion: reads the user-tag
BridgeNodeId N times through the OPC UA server, then reads the diagnostic
counter and asserts the value is at least N (a probe loop or a parallel
client may have bumped it by more, so the comparison is `>=`). NodeId form:
ns=<n>;s=AbLegacy/<gateway>/_Diagnostics/RequestCount. Mirrors the
-SystemConnectionStatusNodeId knob on test-abcip.ps1.
#>
param(
@@ -36,7 +46,8 @@ param(
[string]$PlcType = "Slc500",
[string]$Address = "N7:5",
[string]$OpcUaUrl = "opc.tcp://localhost:4840",
[Parameter(Mandatory)] [string]$BridgeNodeId
[Parameter(Mandatory)] [string]$BridgeNodeId,
[string]$DiagnosticsRequestCountNodeId
)
$ErrorActionPreference = "Stop"
@@ -150,5 +161,40 @@ if ($notifyLines.Count -eq 1) {
$results += @{ Passed = $false; Reason = "deadband notify count $($notifyLines.Count)" }
}
# PR ablegacy-10 / #253 — diagnostic-counter round-trip assertion. After N reads
# against the user-tag BridgeNodeId the auto-emitted _Diagnostics/<host>/RequestCount
# counter must be >= N. The exact equality isn't asserted because a probe loop /
# parallel client may have bumped the counter — the spec is "every read counts".
if ($DiagnosticsRequestCountNodeId) {
Write-Header "DiagnosticsRequestCount (_Diagnostics/RequestCount from $DiagnosticsRequestCountNodeId)"
$diagN = 5
# Read the first counter snapshot to baseline; the assertion compares delta against
# the N OPC UA reads we issue between snapshots so a noisy probe loop doesn't
# invalidate the test.
$baselineOut = & $opcUaCli.File @($opcUaCli.PrefixArgs) `
@("read", "-u", $OpcUaUrl, "-n", $DiagnosticsRequestCountNodeId) 2>&1
$baseline = 0
if (($baselineOut -join "`n") -match '(\d+)') { $baseline = [int64]$Matches[1] }
for ($i = 0; $i -lt $diagN; $i++) {
& $opcUaCli.File @($opcUaCli.PrefixArgs) `
@("read", "-u", $OpcUaUrl, "-n", $BridgeNodeId) | Out-Null
}
$afterOut = & $opcUaCli.File @($opcUaCli.PrefixArgs) `
@("read", "-u", $OpcUaUrl, "-n", $DiagnosticsRequestCountNodeId) 2>&1
$after = 0
if (($afterOut -join "`n") -match '(\d+)') { $after = [int64]$Matches[1] }
$delta = $after - $baseline
if ($delta -ge $diagN) {
Write-Pass "DiagnosticsRequestCount delta $delta >= $diagN OPC UA reads"
$results += @{ Passed = $true }
} else {
Write-Fail "DiagnosticsRequestCount delta $delta < $diagN OPC UA reads (baseline=$baseline after=$after)"
$results += @{ Passed = $false; Reason = "diag delta $delta < $diagN" }
}
}
Write-Summary -Title "AB Legacy e2e" -Results $results
if ($results | Where-Object { -not $_.Passed }) { exit 1 }