fix(grpc-data): H1 port outcome Status passes GoodNoData through (review 1)
This commit is contained in:
@@ -113,8 +113,19 @@ internal sealed class HistoryReadNodeOutcome
|
||||
/// <summary>The per-node result, or null when untouched.</summary>
|
||||
public SdkHistoryReadResult? Result { get; set; }
|
||||
|
||||
/// <summary>The effective operation status a non-SDK caller (H2) reports.</summary>
|
||||
public StatusCode Status => Error?.StatusCode ?? StatusCodes.BadHistoryOperationUnsupported;
|
||||
/// <summary>
|
||||
/// The effective per-node status a non-SDK caller (H2) reports: a non-Good operation status wins; otherwise the
|
||||
/// result's own status, so <c>GoodNoData</c> passes through verbatim (plan §3.3). An untouched operation slot is the
|
||||
/// SDK's pre-seeded <c>BadHistoryOperationUnsupported</c>.
|
||||
/// </summary>
|
||||
public StatusCode Status
|
||||
{
|
||||
get
|
||||
{
|
||||
var operation = Error?.StatusCode ?? StatusCodes.BadHistoryOperationUnsupported;
|
||||
return StatusCode.IsGood(operation) ? Result?.StatusCode ?? StatusCodes.Good : operation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The returned samples (HistoryData or HistoryModifiedData values), empty when none.</summary>
|
||||
public IReadOnlyList<DataValue> Values =>
|
||||
|
||||
@@ -166,7 +166,9 @@ public sealed class HistoryReadPortPagingFuzzTests(HistoryReadPortServerFixture
|
||||
{
|
||||
var outcome = fx.Nm.ReadHistory(details, [new HistoryReadPortItem(realm, id, cp)],
|
||||
fx.Nm.SessionHistoryContinuationScope(session: null), CancellationToken.None)[0];
|
||||
return (outcome.Status.Code, outcome.Values.Select(Render).ToList(), outcome.ContinuationPoint);
|
||||
// The operation slot, as the override's errors[i] (Status folds GoodNoData in; pinned by the parity tests).
|
||||
return (outcome.Error?.StatusCode.Code ?? StatusCodes.BadHistoryOperationUnsupported.Code,
|
||||
outcome.Values.Select(Render).ToList(), outcome.ContinuationPoint);
|
||||
}
|
||||
|
||||
private (uint Status, List<string> Values, byte[]? Cp) OverrideRead(ReadRawModifiedDetails details, NodeId nodeId, byte[]? cp)
|
||||
|
||||
@@ -404,6 +404,28 @@ public sealed class HistoryReadPortParityTests(HistoryReadPortServerFixture fx)
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task The_outcome_status_carries_GoodNoData_and_Bad_operation_statuses_verbatim()
|
||||
{
|
||||
await RunAsync(async () =>
|
||||
{
|
||||
fx.Nm.HistorianDataSource = new ParitySource();
|
||||
HistoryReadNodeOutcome Read(HistoryReadVariant d, string key) =>
|
||||
fx.Nm.ReadHistory(d, [new HistoryReadPortItem(fx.Nodes[key].Realm, fx.Nodes[key].Id)],
|
||||
fx.Nm.SessionHistoryContinuationScope(session: null), CancellationToken.None)[0];
|
||||
|
||||
// §3.3: an empty window is GoodNoData (the result slot), not the Good operation status.
|
||||
Read(new HistoryReadRawVariant(T(0), T(10), 5, ReturnBounds: false), "dbl").Status.Code.ShouldBe(StatusCodes.GoodNoData.Code);
|
||||
Read(new HistoryReadAtTimeVariant([]), "dbl").Status.Code.ShouldBe(StatusCodes.GoodNoData.Code);
|
||||
// A Bad operation status wins, with or without a result slot.
|
||||
Read(new HistoryReadRawVariant(T(0), T(10), 5, ReturnBounds: true, IsReadModified: true), "dbl")
|
||||
.Status.Code.ShouldBe(StatusCodes.BadInvalidArgument.Code);
|
||||
Read(new HistoryReadRawVariant(T(0), T(10), 5, ReturnBounds: false), "plain")
|
||||
.Status.Code.ShouldBe(StatusCodes.BadHistoryOperationUnsupported.Code);
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_node_with_no_historian_tagname_is_unsupported_on_both_paths()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user