test(live): prove Write2 applies a value via supervisory advise on DEV (#212)
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:
@@ -256,6 +256,10 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output)
|
||||
string? sessionId = null;
|
||||
Task? streamTask = null;
|
||||
using CancellationTokenSource streamCancellation = new();
|
||||
MxValue? originalValue = null;
|
||||
bool restored = false;
|
||||
int serverHandle = 0;
|
||||
int itemHandle = 0;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -288,16 +292,33 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output)
|
||||
LogReply("AddItem", addItemReply);
|
||||
Assert.Equal(ProtocolStatusCode.Ok, addItemReply.ProtocolStatus.Code);
|
||||
Assert.True(addItemReply.AddItem.ItemHandle > 0);
|
||||
serverHandle = registerReply.Register.ServerHandle;
|
||||
itemHandle = addItemReply.AddItem.ItemHandle;
|
||||
|
||||
// Supervisory, not plain, advise: MXAccess refuses a user-id-0 write on a
|
||||
// plainly advised item with SecurityError/1008. Proven on the DEV gateway
|
||||
// (wonder-app-vd03, 2026-11-12, #212): on MESReceiver_025.MoveInBatchID, Write2
|
||||
// applied the value after AdviseSupervisory and got SecurityError/1008 after Advise.
|
||||
MxCommandReply adviseReply = await fixture.Service.Invoke(
|
||||
CreateAdviseRequest(
|
||||
CreateAdviseSupervisoryRequest(
|
||||
sessionId,
|
||||
registerReply.Register.ServerHandle,
|
||||
addItemReply.AddItem.ItemHandle),
|
||||
new TestServerCallContext()).ConfigureAwait(false);
|
||||
LogReply("Advise", adviseReply);
|
||||
LogReply("AdviseSupervisory", adviseReply);
|
||||
Assert.Equal(ProtocolStatusCode.Ok, adviseReply.ProtocolStatus.Code);
|
||||
|
||||
// The write below can now really apply, so remember the value to restore.
|
||||
MxEvent initialValue = await eventWriter
|
||||
.WaitForMessageAsync(
|
||||
candidate => candidate.Family == MxEventFamily.OnDataChange
|
||||
&& candidate.ItemHandle == addItemReply.AddItem.ItemHandle,
|
||||
IntegrationTestEnvironment.LiveMxAccessEventTimeout,
|
||||
streamCancellation.Token)
|
||||
.ConfigureAwait(false);
|
||||
LogEvent(initialValue);
|
||||
originalValue = initialValue.Value;
|
||||
|
||||
MxCommandReply writeReply = await fixture.Service.Invoke(
|
||||
CreateWrite2Request(
|
||||
sessionId,
|
||||
@@ -308,11 +329,10 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output)
|
||||
|
||||
// Ok means the worker reached the COM Write2 call and COM accepted it.
|
||||
// InvalidRequest here means the executor rejected the payload
|
||||
// (missing value/timestamp) before reaching MXAccess. Ok does not
|
||||
// mean the provider applied the value: on the windev Galaxy the
|
||||
// default item is security-classified, so the completion carries
|
||||
// SecurityError/1008 (an unauthenticated write refused; Write2 has
|
||||
// no user id). Plain Write gets the same status (#212, 2026-11-12).
|
||||
// (missing value/timestamp) before reaching MXAccess. Ok alone does
|
||||
// not mean the provider applied the value; the completion status
|
||||
// below carries that. (The 2026-11-12 windev run used a plain Advise
|
||||
// and got SecurityError/1008 on the completion; see #212.)
|
||||
Assert.Equal(ProtocolStatusCode.Ok, writeReply.ProtocolStatus.Code);
|
||||
Assert.Equal(MxCommandKind.Write2, writeReply.Kind);
|
||||
|
||||
@@ -337,6 +357,23 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output)
|
||||
Assert.Equal(registerReply.Register.ServerHandle, writeComplete.ServerHandle);
|
||||
Assert.Equal(addItemReply.AddItem.ItemHandle, writeComplete.ItemHandle);
|
||||
|
||||
foreach (MxStatusProxy status in writeComplete.Statuses)
|
||||
{
|
||||
output.WriteLine($"Write2 completion category={status.Category} detail={status.Detail}");
|
||||
}
|
||||
|
||||
// Restore the original value with a plain Write on the same supervisory advise.
|
||||
MxCommandReply restoreReply = await fixture.Service.Invoke(
|
||||
CreateWriteRequest(
|
||||
sessionId,
|
||||
registerReply.Register.ServerHandle,
|
||||
addItemReply.AddItem.ItemHandle,
|
||||
originalValue),
|
||||
new TestServerCallContext()).ConfigureAwait(false);
|
||||
LogReply("Write (restore)", restoreReply);
|
||||
Assert.Equal(ProtocolStatusCode.Ok, restoreReply.ProtocolStatus.Code);
|
||||
restored = true;
|
||||
|
||||
// The stream task must not be in a faulted state. ShutDownAsync's
|
||||
// broad catch would otherwise swallow the fault and silently let
|
||||
// this Write2-parity coverage pass against a broken event pipeline.
|
||||
@@ -346,6 +383,23 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output)
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!restored && originalValue is not null && sessionId is not null && itemHandle != 0)
|
||||
{
|
||||
// Best effort: do not leave the Write2 test value behind after a failed
|
||||
// assertion. Logged, not thrown, so the original failure is not masked.
|
||||
try
|
||||
{
|
||||
MxCommandReply restoreReply = await fixture.Service.Invoke(
|
||||
CreateWriteRequest(sessionId, serverHandle, itemHandle, originalValue),
|
||||
new TestServerCallContext()).ConfigureAwait(false);
|
||||
LogReply("Write (restore after failure)", restoreReply);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
output.WriteLine($"Restore after failure threw {ex.GetType().Name}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel the stream call before draining so StreamEvents observes
|
||||
// cancellation rather than blocking on the channel. Any unhandled
|
||||
// stream-task fault is rethrown from ShutDownAsync into the test.
|
||||
@@ -1539,6 +1593,50 @@ public sealed class WorkerLiveMxAccessSmokeTests(ITestOutputHelper output)
|
||||
};
|
||||
}
|
||||
|
||||
private static MxCommandRequest CreateAdviseSupervisoryRequest(
|
||||
string sessionId,
|
||||
int serverHandle,
|
||||
int itemHandle)
|
||||
{
|
||||
return new MxCommandRequest
|
||||
{
|
||||
SessionId = sessionId,
|
||||
ClientCorrelationId = "live-advise-supervisory",
|
||||
Command = new MxCommand
|
||||
{
|
||||
Kind = MxCommandKind.AdviseSupervisory,
|
||||
AdviseSupervisory = new AdviseSupervisoryCommand
|
||||
{
|
||||
ServerHandle = serverHandle,
|
||||
ItemHandle = itemHandle,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private static MxCommandRequest CreateWriteRequest(
|
||||
string sessionId,
|
||||
int serverHandle,
|
||||
int itemHandle,
|
||||
MxValue value)
|
||||
{
|
||||
return new MxCommandRequest
|
||||
{
|
||||
SessionId = sessionId,
|
||||
ClientCorrelationId = "live-write-restore",
|
||||
Command = new MxCommand
|
||||
{
|
||||
Kind = MxCommandKind.Write,
|
||||
Write = new WriteCommand
|
||||
{
|
||||
ServerHandle = serverHandle,
|
||||
ItemHandle = itemHandle,
|
||||
Value = value,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private static MxCommandRequest CreateWriteRequest(
|
||||
string sessionId,
|
||||
int serverHandle,
|
||||
|
||||
Reference in New Issue
Block a user