test(live): prove Write2 applies a value via supervisory advise on DEV (#212)
ci / nightly-windev (push) Has been skipped
ci / portable (push) Failing after 7m54s
ci / windows-x86 (push) Failing after 10m16s
ci / java (push) Failing after 10m17s

On the DEV gateway (wonder-app-vd03, 2b13564e), Write2 after
AdviseSupervisory applied the value to MESReceiver_025.MoveInBatchID
(0 -> 212212, OnWriteComplete Ok), and the value was restored to 0. After a
plain Advise, the same Write2 got SecurityError/1008, which is exactly what
the windev run saw. So that refusal came from the plain advise. It does not
show that windev has no writable attribute.

- Client.Tests: add the opt-in LiveGatewayWrite2Tests (gated by
  LiveGatewayWriteFact: endpoint, key file and write item env vars). It runs
  supervisory advise -> Write2 -> readback -> restore. The value test passed
  live on vd03. The timestamp-parity test needs a second opt-in; it fails on
  a non-UTC host until #228 is fixed.
- IntegrationTests: the windev Write2 smoke now uses AdviseSupervisory and
  restores the original value. It has not been re-run on windev.
- GatewayTesting.md: document the env vars. code-reviews IntegrationTests-033:
  correct the "no writable attribute" limit.

The run also found that the Write2 timestamp is read as host-local time
(stored +5 h on the UTC-5 box); filed as #228.

Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
This commit is contained in:
Joseph Doherty
2026-11-12 20:40:46 -05:00
parent ebbfaa4c03
commit 7481b95905
5 changed files with 406 additions and 9 deletions
+39 -2
View File
@@ -51,7 +51,7 @@ shutdown request even when a command or event assertion fails. Cleanup failures
in that `finally` block are logged rather than thrown, so a real assertion
failure is never masked by a shutdown timeout.
`WorkerLiveMxAccessSmokeTests` additionally covers seven MXAccess parity paths the
`WorkerLiveMxAccessSmokeTests` additionally covers eight MXAccess parity paths the
fake-worker tests cannot validate:
- a `Write` round-trip against an advised item, asserting both that the reply is
@@ -72,6 +72,13 @@ fake-worker tests cannot validate:
gateway must transition the session to `SessionState.Faulted` with a
non-empty fault description carrying a known worker-client classification
(pipe disconnected / worker faulted / end-of-stream / heartbeat expired),
- a `Write2` (value + `VT_DATE` timestamp) round-trip after `AdviseSupervisory`,
asserting the reply is `Ok` / `MxCommandKind.Write2` and a matching
`OnWriteComplete` arrives, then restoring the original value with a plain
`Write`. It uses a supervisory advise because MXAccess refuses a user-id-0
write on a plainly advised item with `SecurityError`/`1008` (#212). The
completion status is logged, not asserted, because whether the windev item
accepts the write has not been checked since the switch,
- the B8 new COM commands — `AuthenticateUser`, `ArchestrAUserToId`, `Suspend`,
and `Activate` — each asserting a real MXAccess reply (not `InvalidRequest`)
is returned against an added-but-not-advised item, and
@@ -81,7 +88,7 @@ fake-worker tests cannot validate:
or dropping frames; live §3.2 multi-sample conversion is noted as a residual
when the rig does not drive sample-bearing buffered batches on demand.
All eight tests are gated by the same `MXGATEWAY_RUN_LIVE_MXACCESS_TESTS=1`
All nine tests are gated by the same `MXGATEWAY_RUN_LIVE_MXACCESS_TESTS=1`
opt-in variable. Opt-in does not mean unscheduled: the `nightly-windev` job runs
this suite on windev every night at 06:00 UTC and files a Gitea issue when it goes
red (see [Continuous Integration](#continuous-integration)), so the smoke no longer
@@ -122,6 +129,36 @@ The test output includes session id, worker process id, command status,
HRESULT/status diagnostics, event sequence and handles, close status, and worker
stdout/stderr lines emitted during the run.
## Live gateway write (Client.Tests)
`LiveGatewayWrite2Tests` in `clients/dotnet/ZB.MOM.WW.MxGateway.Client.Tests/` drives a
**running gateway** over gRPC with the .NET client (no worker launched by the test), so
it can run from any OS against a deployed box. It writes to a real Galaxy attribute,
so it is skipped unless all of these are set:
| Variable | Meaning |
|---|---|
| `MXGATEWAY_LIVE_GATEWAY_ENDPOINT` | Gateway gRPC endpoint, e.g. `http://<host>:5120`. |
| `MXGATEWAY_LIVE_GATEWAY_API_KEY_FILE` | File (mode 0600) holding the `mxgw_...` key. `MXGATEWAY_LIVE_GATEWAY_API_KEY` works too, but the file keeps the key out of the environment. The key needs `session:open`, `session:close`, `invoke:read`, `invoke:write`, `events:read`; a `Write tag globs` constraint scoped to the test item is enough. |
| `MXGATEWAY_LIVE_GATEWAY_WRITE_ITEM` | A test-only, writable **Int32** attribute. No default on purpose. On the DEV box use a Z28062 receiver attribute such as `MESReceiver_025.MoveInBatchID`, never anything on Z28061. |
| `MXGATEWAY_LIVE_GATEWAY_ASSERT_WRITE2_TIMESTAMP` | `1` also runs `Write2_SupervisoryAdvise_KeepsSentTimestamp`. On a host whose clock is not UTC it fails until #228 is fixed. |
Each test does Register, AddItem, **AdviseSupervisory**, reads the original value from the first
`OnDataChange`, `Write2`s a different value with a timestamp 30 s in the past, waits for the
`OnDataChange` and `OnWriteComplete` (asserting an `Ok` completion), then restores the original
value with a plain `Write` (also on any failure after the original was read).
`Write2_SupervisoryAdvise_AppliesValue` asserts the value was applied and restored.
```bash
MXGATEWAY_LIVE_GATEWAY_ENDPOINT=http://wonder-app-vd03.zmr.zimmer.com:5120 \
MXGATEWAY_LIVE_GATEWAY_API_KEY_FILE=/path/to/key.txt \
MXGATEWAY_LIVE_GATEWAY_WRITE_ITEM=MESReceiver_025.MoveInBatchID \
dotnet test clients/dotnet/ZB.MOM.WW.MxGateway.Client.Tests --filter FullyQualifiedName~LiveGatewayWrite2Tests
```
Run on the DEV box (vd03, gateway `2b13564e`) on 2026-11-12: the value test passed, and the
timestamp test failed with exactly the #228 shift (sent `01:36:51Z`, stored `06:36:51Z`; vd03 is UTC-5).
## Dev-rig Probes
`src/ZB.MOM.WW.MxGateway.Worker.Tests/Probes/` partitions runtime probes from the regular