test(grpc-data): pinned pre-H2 SOURCE option (rig.py up --source-revision), wire tap, H05 v1-origin gate (#921); A09 driver-failure ack revert scenario (#927)

This commit is contained in:
Joseph Doherty
2026-11-28 09:28:59 -05:00
parent a2a1104f20
commit a0901ddf39
7 changed files with 737 additions and 21 deletions
+66 -2
View File
@@ -26,7 +26,7 @@ try
using var manifest = JsonDocument.Parse(await File.ReadAllTextAsync(manifestPath));
var root = manifest.RootElement;
var scenario = arguments.GetValueOrDefault("--scenario", "all");
if (scenario is not ("all" or "D13" or "wire" or "history" or "conditions" or "condition-records")) throw new ArgumentException("Unsupported wire scenario.");
if (scenario is not ("all" or "D13" or "wire" or "history" or "history-v1-origin" or "conditions" or "condition-records")) throw new ArgumentException("Unsupported wire scenario.");
var nodes = root.GetProperty("nodes");
var endpoints = root.GetProperty("endpoints");
var keyPath = root.GetProperty("credentials").GetProperty("data_key_files").GetProperty("source").GetString()!;
@@ -462,7 +462,71 @@ try
["expect"] = expect, ["expectedFound"] = expected,
}));
}
if (scenario is not ("D13" or "history" or "conditions" or "condition-records"))
if (scenario == "history-v1-origin")
{
// lmxopcua#921 (H05 against a pinned pre-H2 origin): what a NEW caller sees from a v1 origin when it asks for the
// features. Capabilities with the full feature header are byte-identical to those without it (no history, no
// conditions, no HistoryRead bit), and a HistoryRead with the header is answered UNIMPLEMENTED: the method does not
// exist on that build. This deliberately sends new-shape calls, so on a wire-tapped origin it is also the tap's
// positive control (the tap must record them).
failurePhase = ProbeFailurePhase.WireOperation;
var fixture = root.GetProperty("fixture");
var rawUri = fixture.GetProperty("namespace_uris").GetProperty("raw").GetString()!;
var historized = fixture.GetProperty("history").GetProperty("historized").GetProperty("raw").GetString()!;
foreach (var node in sourceNodes)
{
var name = node.Name;
failureTarget = name;
var nodeId = node.Value.GetProperty("node_id").GetString()!;
Metadata With(string? features)
{
var headers = Headers(key, "Node", nodeId);
if (features is not null) headers.Add("x-otopcua-data-features", features);
return headers;
}
using var handler = security.Handler(name);
using var channel = GrpcChannel.ForAddress($"https://{name}:4057", new() { HttpHandler = handler });
var client = new W.DataConnectionService.DataConnectionServiceClient(channel);
var deadline = () => DateTime.UtcNow.AddSeconds(20);
var plain = await client.GetCapabilitiesAsync(new() { ProtocolMajor = 1, ProtocolMinor = 3 }, With(null), deadline());
var featured = await client.GetCapabilitiesAsync(new() { ProtocolMajor = 1, ProtocolMinor = 3 }, With("history,conditions"), deadline());
static byte[] Shape(W.CapabilitiesResponse response)
{
// The serving identity aside, the two answers must be the same bytes.
var copy = response.Clone();
copy.Serving = null;
return copy.ToByteArray();
}
var v1Shape = plain.History is null && featured.History is null && plain.Conditions is null && featured.Conditions is null
&& (plain.Operations & 32) == 0 && (featured.Operations & 32) == 0;
var identical = Shape(plain).AsSpan().SequenceEqual(Shape(featured));
string historyRead;
try
{
var request = new W.HistoryReadRequest
{
Budget = new() { TimeoutTicks = TimeSpan.FromSeconds(10).Ticks, MaxItems = 1, MaxBytes = 1024 * 1024 },
Raw = new() { NumValuesPerNode = 5, End = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(DateTimeOffset.UtcNow) },
};
request.Items.Add(new W.HistoryReadItem { CorrelationId = "one", View = new() { Address = new() { OriginClusterId = "SOURCE",
NamespaceUri = rawUri, IdentifierKind = "string", Identifier = historized }, Realm = (int)DataRealm.Raw, Subject = historized } });
await client.HistoryReadAsync(request, With("history"), deadline());
historyRead = "OK";
}
catch (RpcException error) { historyRead = error.StatusCode.ToString(); }
results.Add(new("history-v1-origin-" + name, "history-v1-origin", v1Shape && identical && historyRead == "Unimplemented", 3, new()
{
["withoutHeader"] = new { operations = plain.Operations, historyPresent = plain.History is not null, conditionsPresent = plain.Conditions is not null,
protocolMinor = plain.ProtocolMinor, bytes = plain.CalculateSize() },
["withHeader"] = new { operations = featured.Operations, historyPresent = featured.History is not null, conditionsPresent = featured.Conditions is not null,
protocolMinor = featured.ProtocolMinor, bytes = featured.CalculateSize() },
["byteIdentical"] = identical,
["historyReadWithHeader"] = historyRead,
["serving"] = featured.Serving.ToString(),
}));
}
}
if (scenario is not ("D13" or "history" or "history-v1-origin" or "conditions" or "condition-records"))
{
var fixture = root.GetProperty("fixture");
var rawUri = fixture.GetProperty("namespace_uris").GetProperty("raw").GetString()!;