The original three-stage design (probe / driver-loopback / forward- bridge) only proved driver-write → server-read. It missed: - OPC UA write → server → driver → PLC (the reverse direction) - server-side data-change notifications actually firing (a stale subscription can still let a read-after-the-fact return the new value and look fine) Extend _common.ps1 with two helpers: - Test-OpcUaWriteBridge: otopcua-cli write the NodeId -> wait 3s -> driver CLI read the PLC side, assert equality. - Test-SubscribeSeesChange: Start-Process otopcua-cli subscribe in the background with --duration N, settle 2s, driver-side write, wait for the subscription window to close, assert captured stdout contains the new value. Wire both into test-modbus / test-abcip / test-ablegacy / test-s7 / test-focas / test-twincat after the existing forward-bridge stage. Update README to describe the five-stage design + note that the published NodeId must be writable for stages 4 + 5. Also prepend UTF-8 BOM to every script in scripts/e2e so Windows PowerShell 5.1 parsers agree on em-dash byte sequences the way PowerShell 7 already does. The scripts still #Requires -Version 7.0 — the BOM is purely defensive for IDE / CI step parsers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
100 lines
3.4 KiB
PowerShell
100 lines
3.4 KiB
PowerShell
#Requires -Version 7.0
|
|
<#
|
|
.SYNOPSIS
|
|
End-to-end CLI test for the AB Legacy (PCCC) driver.
|
|
|
|
.DESCRIPTION
|
|
**KNOWN-BROKEN upstream (ab_server PCCC dispatcher gap, verified 2026-04-21).**
|
|
Works against real SLC / MicroLogix / PLC-5 hardware or a RSEmulate 500
|
|
golden-box. Against the Docker ab_server the tests deliberately skip —
|
|
same gate as tests/.../AbLegacy.IntegrationTests (AB_LEGACY_TRUST_WIRE=1).
|
|
|
|
Five assertions: probe / driver-loopback / forward-bridge / reverse-bridge /
|
|
subscribe-sees-change.
|
|
|
|
.PARAMETER Gateway
|
|
ab://host[:port]/cip-path. Default ab://127.0.0.1/1,0.
|
|
|
|
.PARAMETER PlcType
|
|
Slc500 / MicroLogix / Plc5 / LogixPccc (default Slc500).
|
|
|
|
.PARAMETER Address
|
|
PCCC address to exercise. Default N7:5.
|
|
|
|
.PARAMETER OpcUaUrl
|
|
OtOpcUa server endpoint.
|
|
|
|
.PARAMETER BridgeNodeId
|
|
NodeId at which the server publishes the Address.
|
|
#>
|
|
|
|
param(
|
|
[string]$Gateway = "ab://127.0.0.1/1,0",
|
|
[string]$PlcType = "Slc500",
|
|
[string]$Address = "N7:5",
|
|
[string]$OpcUaUrl = "opc.tcp://localhost:4840",
|
|
[Parameter(Mandatory)] [string]$BridgeNodeId
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
. "$PSScriptRoot/_common.ps1"
|
|
|
|
# Skip-gate: the driver CLI's underlying AbLegacyServerFixture-equivalent
|
|
# check — operators point at real hardware by setting AB_LEGACY_TRUST_WIRE=1.
|
|
# Without the opt-in we skip (don't run against the known-broken ab_server).
|
|
if (-not ($env:AB_LEGACY_TRUST_WIRE -eq "1" -or $env:AB_LEGACY_TRUST_WIRE -eq "true")) {
|
|
Write-Skip "AB_LEGACY_TRUST_WIRE not set — skipping (ab_server PCCC is upstream-broken; set =1 against real hardware / RSEmulate)."
|
|
exit 0
|
|
}
|
|
|
|
$abLegacyCli = Get-CliInvocation `
|
|
-ProjectFolder "src/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Cli" `
|
|
-ExeName "otopcua-ablegacy-cli"
|
|
$opcUaCli = Get-CliInvocation `
|
|
-ProjectFolder "src/ZB.MOM.WW.OtOpcUa.Client.CLI" `
|
|
-ExeName "otopcua-cli"
|
|
|
|
$commonAbLegacy = @("-g", $Gateway, "-P", $PlcType)
|
|
$results = @()
|
|
|
|
$results += Test-Probe `
|
|
-Cli $abLegacyCli `
|
|
-ProbeArgs (@("probe") + $commonAbLegacy + @("-a", "N7:0"))
|
|
|
|
$writeValue = Get-Random -Minimum 1 -Maximum 9999
|
|
$results += Test-DriverLoopback `
|
|
-Cli $abLegacyCli `
|
|
-WriteArgs (@("write") + $commonAbLegacy + @("-a", $Address, "-t", "Int", "-v", $writeValue)) `
|
|
-ReadArgs (@("read") + $commonAbLegacy + @("-a", $Address, "-t", "Int")) `
|
|
-ExpectedValue "$writeValue"
|
|
|
|
$bridgeValue = Get-Random -Minimum 10000 -Maximum 19999
|
|
$results += Test-ServerBridge `
|
|
-DriverCli $abLegacyCli `
|
|
-DriverWriteArgs (@("write") + $commonAbLegacy + @("-a", $Address, "-t", "Int", "-v", $bridgeValue)) `
|
|
-OpcUaCli $opcUaCli `
|
|
-OpcUaUrl $OpcUaUrl `
|
|
-OpcUaNodeId $BridgeNodeId `
|
|
-ExpectedValue "$bridgeValue"
|
|
|
|
$reverseValue = Get-Random -Minimum 20000 -Maximum 29999
|
|
$results += Test-OpcUaWriteBridge `
|
|
-OpcUaCli $opcUaCli `
|
|
-OpcUaUrl $OpcUaUrl `
|
|
-OpcUaNodeId $BridgeNodeId `
|
|
-DriverCli $abLegacyCli `
|
|
-DriverReadArgs (@("read") + $commonAbLegacy + @("-a", $Address, "-t", "Int")) `
|
|
-ExpectedValue "$reverseValue"
|
|
|
|
$subValue = Get-Random -Minimum 30000 -Maximum 32766
|
|
$results += Test-SubscribeSeesChange `
|
|
-OpcUaCli $opcUaCli `
|
|
-OpcUaUrl $OpcUaUrl `
|
|
-OpcUaNodeId $BridgeNodeId `
|
|
-DriverCli $abLegacyCli `
|
|
-DriverWriteArgs (@("write") + $commonAbLegacy + @("-a", $Address, "-t", "Int", "-v", $subValue)) `
|
|
-ExpectedValue "$subValue"
|
|
|
|
Write-Summary -Title "AB Legacy e2e" -Results $results
|
|
if ($results | Where-Object { -not $_.Passed }) { exit 1 }
|