The driver-layer integration tests confirm the driver sees the PLC, and
the Client.CLI tests confirm the client sees the server. Nothing glued
them end-to-end until this PR.
- scripts/e2e/_common.ps1: shared helpers — CLI invocation (published-
binary OR `dotnet run` fallback), Test-Probe / Test-DriverLoopback /
Test-ServerBridge (all return @{Passed;Reason} hashtables).
- scripts/e2e/test-<modbus|abcip|ablegacy|s7|focas|twincat>.ps1: per-
driver three-stage script (probe → driver-loopback → server-bridge).
AB Legacy / FOCAS / TwinCAT are gated behind *_TRUST_WIRE env vars
since they need real hardware (#222) or a licensed runtime (#221).
- scripts/e2e/test-phase7-virtualtags.ps1: writes a Modbus HR, reads
the server-side VirtualTag (VT = input * 2) back via OPC UA, triggers
+ clears a scripted alarm. Exercises the Phase 7 CachedTagUpstreamSource
+ ScriptedAlarmEngine path.
- scripts/e2e/test-all.ps1: reads e2e-config.json sidecar, runs each
present driver, prints a FINAL MATRIX (PASS/FAIL/SKIP). Missing
sections SKIP rather than fail hard.
- scripts/e2e/e2e-config.sample.json: commented sample — each dev's
NodeIds are local-seed-specific so e2e-config.json is .gitignore-d.
- scripts/e2e/README.md: full walkthrough — prereqs, three-stage design,
env-var gates, expected matrix, why this is separate from `dotnet test`.
Tasks #249-#251 shipped Modbus/AbCip/AbLegacy/S7/TwinCAT CLIs but left
FOCAS out. Since test-focas.ps1 needs it, the 6th CLI ships here:
- src/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Cli: probe/read/write/subscribe
commands, AssemblyName `otopcua-focas-cli`. WriteCommand.ParseValue
handles the full FocasDataType enum (Bit/Byte/Int16/Int32/Float32/
Float64/String — no UInt variants; the FOCAS protocol exposes signed
PMC + Fanuc-Float only). Default DataType is Int16 to match the PMC
register convention.
Full-solution build clean (0 errors). FOCAS CLI wired into
ZB.MOM.WW.OtOpcUa.slnx. No .Tests project for the FOCAS CLI yet —
symmetric with how ProbeCommand has no unit-testable pure logic in the
other 5 CLIs either; WriteCommand.ParseValue parity will land in a
follow-up to keep this PR scoped.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
193 lines
6.7 KiB
PowerShell
193 lines
6.7 KiB
PowerShell
#Requires -Version 7.0
|
|
<#
|
|
.SYNOPSIS
|
|
Runs every scripts/e2e/test-*.ps1 and tallies PASS / FAIL / SKIP.
|
|
|
|
.DESCRIPTION
|
|
The per-protocol scripts require protocol-specific NodeIds that depend on
|
|
your server's config DB seed. This runner expects a JSON sidecar at
|
|
scripts/e2e/e2e-config.json (not checked in — see README) with one entry
|
|
per driver giving the NodeIds + endpoints to pass through. Any driver
|
|
missing from the sidecar is skipped with a clear message rather than
|
|
failing hard.
|
|
|
|
.PARAMETER ConfigFile
|
|
Path to the sidecar JSON. Default: scripts/e2e/e2e-config.json.
|
|
|
|
.PARAMETER OpcUaUrl
|
|
Default OPC UA endpoint passed to each per-driver script. Default
|
|
opc.tcp://localhost:4840. Individual entries in the config file can override.
|
|
#>
|
|
|
|
param(
|
|
[string]$ConfigFile = "$PSScriptRoot/e2e-config.json",
|
|
[string]$OpcUaUrl = "opc.tcp://localhost:4840"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
. "$PSScriptRoot/_common.ps1"
|
|
|
|
if (-not (Test-Path $ConfigFile)) {
|
|
Write-Fail "no config at $ConfigFile — copy e2e-config.sample.json + fill in your NodeIds first (see README)"
|
|
exit 2
|
|
}
|
|
|
|
$config = Get-Content $ConfigFile -Raw | ConvertFrom-Json
|
|
$summary = [ordered]@{}
|
|
|
|
function Run-Suite {
|
|
param(
|
|
[string]$Name,
|
|
[scriptblock]$Action
|
|
)
|
|
try {
|
|
& $Action
|
|
$summary[$Name] = if ($LASTEXITCODE -eq 0) { "PASS" } else { "FAIL" }
|
|
}
|
|
catch {
|
|
Write-Fail "$Name runner crashed: $_"
|
|
$summary[$Name] = "FAIL"
|
|
}
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Modbus
|
|
# ---------------------------------------------------------------------------
|
|
|
|
if ($config.modbus) {
|
|
Write-Header "== MODBUS =="
|
|
Run-Suite "modbus" {
|
|
& "$PSScriptRoot/test-modbus.ps1" `
|
|
-ModbusHost $config.modbus.endpoint `
|
|
-OpcUaUrl ($config.modbus.opcUaUrl ?? $OpcUaUrl) `
|
|
-BridgeNodeId $config.modbus.bridgeNodeId
|
|
}
|
|
}
|
|
else { $summary["modbus"] = "SKIP (no config entry)" }
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# AB CIP
|
|
# ---------------------------------------------------------------------------
|
|
|
|
if ($config.abcip) {
|
|
Write-Header "== AB CIP =="
|
|
Run-Suite "abcip" {
|
|
& "$PSScriptRoot/test-abcip.ps1" `
|
|
-Gateway $config.abcip.gateway `
|
|
-Family ($config.abcip.family ?? "ControlLogix") `
|
|
-TagPath ($config.abcip.tagPath ?? "TestDINT") `
|
|
-OpcUaUrl ($config.abcip.opcUaUrl ?? $OpcUaUrl) `
|
|
-BridgeNodeId $config.abcip.bridgeNodeId
|
|
}
|
|
}
|
|
else { $summary["abcip"] = "SKIP (no config entry)" }
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# AB Legacy
|
|
# ---------------------------------------------------------------------------
|
|
|
|
if ($config.ablegacy) {
|
|
Write-Header "== AB LEGACY =="
|
|
Run-Suite "ablegacy" {
|
|
& "$PSScriptRoot/test-ablegacy.ps1" `
|
|
-Gateway $config.ablegacy.gateway `
|
|
-PlcType ($config.ablegacy.plcType ?? "Slc500") `
|
|
-Address ($config.ablegacy.address ?? "N7:5") `
|
|
-OpcUaUrl ($config.ablegacy.opcUaUrl ?? $OpcUaUrl) `
|
|
-BridgeNodeId $config.ablegacy.bridgeNodeId
|
|
}
|
|
}
|
|
else { $summary["ablegacy"] = "SKIP (no config entry)" }
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# S7
|
|
# ---------------------------------------------------------------------------
|
|
|
|
if ($config.s7) {
|
|
Write-Header "== S7 =="
|
|
Run-Suite "s7" {
|
|
& "$PSScriptRoot/test-s7.ps1" `
|
|
-S7Host $config.s7.endpoint `
|
|
-Cpu ($config.s7.cpu ?? "S71500") `
|
|
-Slot ($config.s7.slot ?? 0) `
|
|
-Address ($config.s7.address ?? "DB1.DBW0") `
|
|
-OpcUaUrl ($config.s7.opcUaUrl ?? $OpcUaUrl) `
|
|
-BridgeNodeId $config.s7.bridgeNodeId
|
|
}
|
|
}
|
|
else { $summary["s7"] = "SKIP (no config entry)" }
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# FOCAS
|
|
# ---------------------------------------------------------------------------
|
|
|
|
if ($config.focas) {
|
|
Write-Header "== FOCAS =="
|
|
Run-Suite "focas" {
|
|
& "$PSScriptRoot/test-focas.ps1" `
|
|
-CncHost $config.focas.host `
|
|
-CncPort ($config.focas.port ?? 8193) `
|
|
-Address ($config.focas.address ?? "R100") `
|
|
-OpcUaUrl ($config.focas.opcUaUrl ?? $OpcUaUrl) `
|
|
-BridgeNodeId $config.focas.bridgeNodeId
|
|
}
|
|
}
|
|
else { $summary["focas"] = "SKIP (no config entry)" }
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# TwinCAT
|
|
# ---------------------------------------------------------------------------
|
|
|
|
if ($config.twincat) {
|
|
Write-Header "== TWINCAT =="
|
|
Run-Suite "twincat" {
|
|
& "$PSScriptRoot/test-twincat.ps1" `
|
|
-AmsNetId $config.twincat.amsNetId `
|
|
-AmsPort ($config.twincat.amsPort ?? 851) `
|
|
-SymbolPath ($config.twincat.symbolPath ?? "MAIN.iCounter") `
|
|
-OpcUaUrl ($config.twincat.opcUaUrl ?? $OpcUaUrl) `
|
|
-BridgeNodeId $config.twincat.bridgeNodeId
|
|
}
|
|
}
|
|
else { $summary["twincat"] = "SKIP (no config entry)" }
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Phase 7 virtual tags + scripted alarms
|
|
# ---------------------------------------------------------------------------
|
|
|
|
if ($config.phase7) {
|
|
Write-Header "== PHASE 7 virtual tags + scripted alarms =="
|
|
Run-Suite "phase7" {
|
|
& "$PSScriptRoot/test-phase7-virtualtags.ps1" `
|
|
-ModbusHost ($config.phase7.modbusEndpoint ?? $config.modbus.endpoint) `
|
|
-OpcUaUrl ($config.phase7.opcUaUrl ?? $OpcUaUrl) `
|
|
-InputNodeId $config.phase7.inputNodeId `
|
|
-VirtualNodeId $config.phase7.virtualNodeId `
|
|
-AlarmNodeId ($config.phase7.alarmNodeId ?? $null)
|
|
}
|
|
}
|
|
else { $summary["phase7"] = "SKIP (no config entry)" }
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Final matrix
|
|
# ---------------------------------------------------------------------------
|
|
|
|
Write-Host ""
|
|
Write-Host "==================== FINAL MATRIX ====================" -ForegroundColor Cyan
|
|
$summary.GetEnumerator() | ForEach-Object {
|
|
$color = switch -Wildcard ($_.Value) {
|
|
"PASS" { "Green" }
|
|
"FAIL" { "Red" }
|
|
"SKIP*" { "Yellow" }
|
|
default { "Gray" }
|
|
}
|
|
Write-Host (" {0,-10} {1}" -f $_.Key, $_.Value) -ForegroundColor $color
|
|
}
|
|
|
|
$failed = ($summary.Values | Where-Object { $_ -eq "FAIL" }).Count
|
|
if ($failed -gt 0) {
|
|
Write-Host "$failed suite(s) failed." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
Write-Host "All present suites passed." -ForegroundColor Green
|