AbServerProfileGate — static helper that reads `AB_SERVER_PROFILE` env var (defaults to "abserver") + exposes `SkipUnless(params string[] requiredProfiles)` matching the MODBUS_SIM_PROFILE pattern the DL205StringQuirkTests uses one directory over. Emulate-only tests call `AbServerProfileGate.SkipUnless("emulate")` at the top of each fact body; ab_server-default runs see them skip with a clear message pointing at the Emulate setup steps.
AbCipEmulateUdtReadTests — one test proving the #194 whole-UDT read optimization works against the real Logix Template Object, not just the golden byte buffers the unit suite uses. Builds an `AbCipDriverOptions` with a Structure tag `Motor1 : Motor_UDT` that has three declared members (Speed : DINT, Torque : REAL, Status : DINT), reads them via the `.Speed / .Torque / .Status` dotted-tag syntax, asserts the driver gets the grouped whole-UDT path + decodes each at the right offset. Required seed values documented inline + in LogixProject/README.md: Speed=1800, Torque=42.5f, Status=0x0001.
AbCipEmulateAlmdTests — one test proving the #177 ALMD projection fires `OnAlarmEvent` when a real ALMD instruction's `In` edge rises, not just the fake `InFaulted` timer edges the unit suite drives. Needs a `SimulateAlarm : BOOL` tag routed through `MainRoutine` ladder (`XIC SimulateAlarm OTE HighTempAlarm.In`) so the test case can pulse the input via the existing `IWritable.WriteAsync` path instead of scripting Emulate via its own socket. Alarm-projection options carry `EnableAlarmProjection = true` + 200 ms poll interval; a `TaskCompletionSource` gates the raise-event assertion with a 5 s deadline. Cleanup writes SimulateAlarm=false so consecutive runs start from known state.
LogixProject/README.md — the Studio 5000 project state the Emulate-tier tests depend on. Explains why L5X over ACD (text diff, reproducible import, no per-install state), the UDT + tag + routine structure, how to bring it up on the Emulate PC. Ships as a stub pending actual author + L5X export + commit; the README itself keeps the requirements visible so the L5X author has a checklist.
docs/drivers/AbServer-Test-Fixture.md — new §Logix Emulate golden-box tier section with the coverage-promotion table (ab_server / Emulate / hardware per gap), the setup-env-var recipe, the costs to accept (license, Hyper-V conflict, manual lifecycle). "When to trust" table extended from 3 columns (ab_server / unit / rig) to 4 (ab_server / unit / Logix Emulate / rig); two new rows for EtherNet/IP embedded-switch + redundant-chassis failover that even Emulate can't help with. Follow-up candidates list gets Logix Emulate as option 1 ahead of the pre-existing "extend ab_server upstream" + "stand up a lab rig". See-also file list gains AbServerProfileGate.cs + Docker/ + Emulate/ + LogixProject/README.md entries.
docs/v2/dev-environment.md — §C Integration host gains a Rockwell Studio 5000 Logix Emulate row: purpose (AB CIP golden-box tier closing UDT/ALMD/AOI/safety/ConnectionSize gaps), type (Windows-only, Hyper-V conflict matching TwinCAT XAR's constraint), port 44818, credentials note, owner split between integration-host admin for license+install and developer for per-session runtime start.
Verified: Emulate tests skip cleanly when AB_SERVER_PROFILE is unset — both `[SKIP]` with the operator-facing message pointing at the env-var setup. Whole-solution build 0 errors. Tests will transition from skip → pass once the L5X + Emulate PC land per #223.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
2.6 KiB
C#
53 lines
2.6 KiB
C#
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.IntegrationTests;
|
|
|
|
/// <summary>
|
|
/// Runtime gate that lets an integration-test class declare which target-server tier
|
|
/// it requires. Reads <c>AB_SERVER_PROFILE</c> from the environment; tests call
|
|
/// <see cref="SkipUnless"/> with the profile names they support + skip otherwise.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Two tiers today:</para>
|
|
/// <list type="bullet">
|
|
/// <item><c>abserver</c> (default) — the Dockerized libplctag <c>ab_server</c>
|
|
/// simulator. Covers atomic reads / writes / basic discovery across the four
|
|
/// families (ControlLogix / CompactLogix / Micro800 / GuardLogix).</item>
|
|
/// <item><c>emulate</c> — Rockwell Studio 5000 Logix Emulate on an operator's
|
|
/// Windows box, exposed via <c>AB_SERVER_ENDPOINT</c>. Adds real UDT / ALMD /
|
|
/// AOI / Program-scoped-tag coverage that ab_server can't emulate. Tier-gated
|
|
/// because Emulate is per-seat licensed + Windows-only + manually launched;
|
|
/// a stock `dotnet test` run against ab_server must skip Emulate-only classes
|
|
/// cleanly.</item>
|
|
/// </list>
|
|
/// <para>Tests assert their target tier at the top of each <c>[Fact]</c> /
|
|
/// <c>[Theory]</c> body, mirroring the <c>MODBUS_SIM_PROFILE</c> gate pattern in
|
|
/// <c>tests/.../Modbus.IntegrationTests/DL205/DL205StringQuirkTests.cs</c>.</para>
|
|
/// </remarks>
|
|
public static class AbServerProfileGate
|
|
{
|
|
public const string Default = "abserver";
|
|
public const string Emulate = "emulate";
|
|
|
|
/// <summary>Active profile from <c>AB_SERVER_PROFILE</c>; defaults to <see cref="Default"/>.</summary>
|
|
public static string CurrentProfile =>
|
|
Environment.GetEnvironmentVariable("AB_SERVER_PROFILE") is { Length: > 0 } raw
|
|
? raw.Trim().ToLowerInvariant()
|
|
: Default;
|
|
|
|
/// <summary>
|
|
/// Skip the calling test via <c>Assert.Skip</c> when <see cref="CurrentProfile"/>
|
|
/// isn't in <paramref name="requiredProfiles"/>. Case-insensitive match.
|
|
/// </summary>
|
|
public static void SkipUnless(params string[] requiredProfiles)
|
|
{
|
|
foreach (var p in requiredProfiles)
|
|
if (string.Equals(p, CurrentProfile, StringComparison.OrdinalIgnoreCase))
|
|
return;
|
|
Assert.Skip(
|
|
$"Test requires AB_SERVER_PROFILE in {{{string.Join(", ", requiredProfiles)}}}; " +
|
|
$"current value is '{CurrentProfile}'. " +
|
|
$"Set AB_SERVER_PROFILE=emulate + point AB_SERVER_ENDPOINT at a Logix Emulate instance to run the golden-box-tier tests.");
|
|
}
|
|
}
|