Task #224 close — AB Legacy PCCC fixture: add AB_LEGACY_TRUST_WIRE opt-in for wire-level runs
The ab_server Docker simulator accepts TCP at :44818 when started with
--plc=SLC500 but its PCCC dispatcher is a confirmed upstream gap
(verified 2026-04-21 with --debug=5: zero request logs when libplctag
issues a read, every read surfaces BadCommunicationError 0x80050000).
Previous behavior — when Docker was up, the three smoke tests ran and
all failed on every integration-host run. Noise, not signal.
New behavior — AbLegacyServerFixture gates on a new env var
AB_LEGACY_TRUST_WIRE:
Endpoint reachable? | TRUST_WIRE set? | Result
--------------------+-----------------+------------------------------
No | — | Skip ("not reachable")
Yes | No | Skip ("ab_server PCCC gap")
Yes | 1 / true | Run
The fixture's new skip reason explicitly names the upstream gap + the
resolution paths (upstream bug / RSEmulate golden-box / real hardware
via task #222 lab rig). Operators with a real SLC 5/05 / MicroLogix
1100/1400 / PLC-5 or an Emulate box set AB_LEGACY_ENDPOINT + TRUST_WIRE
and the smoke tests round-trip cleanly.
Updated docs:
- tests/.../Docker/README.md — new env-var table + three-case gate matrix
- Known limitations section refreshed to "confirmed upstream gap"
Verified locally:
- Docker down: 2 skipped.
- Docker up + TRUST_WIRE unset: 2 skipped (upstream-gap message).
- Docker up + TRUST_WIRE=1: 4 run, 4 fail BadCommunicationError (ab_server gap as expected).
- Unit suite: 96 passed / 0 failed (regression-clean).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,16 @@ public sealed class AbLegacyServerFixture : IAsyncLifetime
|
||||
{
|
||||
private const string EndpointEnvVar = "AB_LEGACY_ENDPOINT";
|
||||
|
||||
/// <summary>
|
||||
/// Opt-in flag that promises the endpoint can actually round-trip PCCC reads/writes
|
||||
/// (real SLC 5/05 / MicroLogix 1100/1400 / PLC-5 hardware, or a RSEmulate 500
|
||||
/// golden-box per <c>docs/v2/lmx-followups.md</c>). Without this, the fixture assumes
|
||||
/// the endpoint is libplctag's <c>ab_server --plc=SLC500</c> Docker container — whose
|
||||
/// PCCC dispatcher is a known upstream gap — and skips cleanly rather than failing
|
||||
/// every test with <c>BadCommunicationError</c>.
|
||||
/// </summary>
|
||||
private const string TrustWireEnvVar = "AB_LEGACY_TRUST_WIRE";
|
||||
|
||||
/// <summary>Standard EtherNet/IP port. PCCC-over-CIP rides on the same port as
|
||||
/// native CIP; the differentiator is the <c>--plc</c> flag ab_server was started
|
||||
/// with, not a different TCP listener.</summary>
|
||||
@@ -46,22 +56,49 @@ public sealed class AbLegacyServerFixture : IAsyncLifetime
|
||||
if (parts.Length == 2 && int.TryParse(parts[1], out var p)) Port = p;
|
||||
}
|
||||
|
||||
if (!TcpProbe(Host, Port))
|
||||
{
|
||||
SkipReason =
|
||||
$"AB Legacy PCCC simulator at {Host}:{Port} not reachable within 2 s. " +
|
||||
$"Start the Docker container (docker compose -f Docker/docker-compose.yml " +
|
||||
$"--profile slc500 up -d) or override {EndpointEnvVar}.";
|
||||
}
|
||||
SkipReason = ResolveSkipReason(Host, Port);
|
||||
}
|
||||
|
||||
public ValueTask InitializeAsync() => ValueTask.CompletedTask;
|
||||
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Used by <see cref="AbLegacyFactAttribute"/> + <see cref="AbLegacyTheoryAttribute"/>
|
||||
/// during test-class construction — gates whether the test runs at all. Duplicates the
|
||||
/// fixture logic because attribute ctors fire before the collection fixture instance
|
||||
/// exists.
|
||||
/// </summary>
|
||||
public static bool IsServerAvailable()
|
||||
{
|
||||
var (host, port) = ResolveEndpoint();
|
||||
return TcpProbe(host, port);
|
||||
return ResolveSkipReason(host, port) is null;
|
||||
}
|
||||
|
||||
private static string? ResolveSkipReason(string host, int port)
|
||||
{
|
||||
if (!TcpProbe(host, port))
|
||||
{
|
||||
return $"AB Legacy PCCC endpoint at {host}:{port} not reachable within 2 s. " +
|
||||
$"Start the Docker container (docker compose -f Docker/docker-compose.yml " +
|
||||
$"--profile slc500 up -d), attach real hardware, or override {EndpointEnvVar}.";
|
||||
}
|
||||
|
||||
// TCP reaches — but is the peer a real PLC (wire-trustworthy) or ab_server's PCCC
|
||||
// mode (dispatcher is upstream-broken, every read surfaces BadCommunicationError)?
|
||||
// We can't detect it at the wire without issuing a full libplctag session, so we
|
||||
// require an explicit opt-in for wire-level runs. See
|
||||
// `tests/.../Docker/README.md` §"Known limitations" for the upstream-tracking pointer.
|
||||
if (Environment.GetEnvironmentVariable(TrustWireEnvVar) is not { Length: > 0 } trust
|
||||
|| !(trust == "1" || string.Equals(trust, "true", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return $"AB Legacy endpoint at {host}:{port} is reachable but {TrustWireEnvVar} is not set. " +
|
||||
"ab_server's PCCC dispatcher is a known upstream gap (libplctag/libplctag), so by " +
|
||||
"default the integration suite assumes the simulator is in play and skips. Set " +
|
||||
$"{TrustWireEnvVar}=1 when pointing at real SLC 5/05 / MicroLogix 1100/1400 / PLC-5 " +
|
||||
"hardware or a RSEmulate 500 golden-box.";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static (string Host, int Port) ResolveEndpoint()
|
||||
@@ -129,16 +166,19 @@ public sealed class AbLegacyServerCollection : Xunit.ICollectionFixture<AbLegacy
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>[Fact]</c>-equivalent that skips when the PCCC simulator isn't reachable.
|
||||
/// <c>[Fact]</c>-equivalent that skips when the PCCC endpoint isn't wire-trustworthy.
|
||||
/// See <see cref="AbLegacyServerFixture"/> for the exact skip semantics.
|
||||
/// </summary>
|
||||
public sealed class AbLegacyFactAttribute : FactAttribute
|
||||
{
|
||||
public AbLegacyFactAttribute()
|
||||
{
|
||||
if (!AbLegacyServerFixture.IsServerAvailable())
|
||||
Skip = "AB Legacy PCCC simulator not reachable. Start the Docker container " +
|
||||
"(docker compose -f Docker/docker-compose.yml --profile slc500 up -d) " +
|
||||
"or set AB_LEGACY_ENDPOINT.";
|
||||
Skip = "AB Legacy PCCC endpoint not wire-trustworthy. Either no simulator is " +
|
||||
"running, or the Docker ab_server is up but AB_LEGACY_TRUST_WIRE is not " +
|
||||
"set (ab_server's PCCC dispatcher is a known upstream gap). Set " +
|
||||
"AB_LEGACY_TRUST_WIRE=1 when pointing AB_LEGACY_ENDPOINT at real hardware " +
|
||||
"or a RSEmulate 500 golden-box.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +190,10 @@ public sealed class AbLegacyTheoryAttribute : TheoryAttribute
|
||||
public AbLegacyTheoryAttribute()
|
||||
{
|
||||
if (!AbLegacyServerFixture.IsServerAvailable())
|
||||
Skip = "AB Legacy PCCC simulator not reachable. Start the Docker container " +
|
||||
"(docker compose -f Docker/docker-compose.yml --profile slc500 up -d) " +
|
||||
"or set AB_LEGACY_ENDPOINT.";
|
||||
Skip = "AB Legacy PCCC endpoint not wire-trustworthy. Either no simulator is " +
|
||||
"running, or the Docker ab_server is up but AB_LEGACY_TRUST_WIRE is not " +
|
||||
"set (ab_server's PCCC dispatcher is a known upstream gap). Set " +
|
||||
"AB_LEGACY_TRUST_WIRE=1 when pointing AB_LEGACY_ENDPOINT at real hardware " +
|
||||
"or a RSEmulate 500 golden-box.";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user