test(grpc-data): A2b P + tolerance — Galaxy opt-in rides the artifact; 'unknown' bits move off 128/256
This commit is contained in:
+2
-2
@@ -256,8 +256,8 @@ public sealed class GrpcDataArtifactReadTests
|
||||
[Theory]
|
||||
[InlineData(1073741824, 0)]
|
||||
[InlineData(5 | 1073741824, 5)]
|
||||
[InlineData(5 | 128, 5)] // 128 (AlarmAcknowledge) is still reserved; 32 became understood in H2, 64 in A2a
|
||||
[InlineData(5 | 32 | 64 | 128, 5 | 32 | 64)]
|
||||
[InlineData(5 | 512, 5)] // 512 (AlarmShelve) is still reserved; 32 became understood in H2, 64 in A2a, 128/256 in A2b
|
||||
[InlineData(5 | 32 | 64 | 128 | 512, 5 | 32 | 64 | 128)]
|
||||
public void Unknown_operation_bit_on_a_connection_or_export_parses_and_grants_nothing(int authored, int understood)
|
||||
{
|
||||
var root = Fixture();
|
||||
|
||||
+8
-4
@@ -72,18 +72,22 @@ public sealed class GrpcDataConditionArtifactReadTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AllowGalaxyServiceAck_without_AlarmAcknowledge_fails_closed_and_with_it_is_tolerated_and_inert()
|
||||
public void AllowGalaxyServiceAck_without_AlarmAcknowledge_fails_closed_and_with_it_rides_the_artifact()
|
||||
{
|
||||
var root = Fixture();
|
||||
root["DataExports"]![0]!["AllowGalaxyServiceAck"] = true;
|
||||
using (var bad = DeploymentArtifact.Open(Blob(root)))
|
||||
Should.Throw<InvalidDataException>(() => bad.ParseDataExports(NodeA));
|
||||
// A newer (A2b) central authors both: this build keeps the row; 128 is outside Understood, so it grants nothing.
|
||||
root["DataExports"]![0]!["AllowedOperations"] = 5 | 128;
|
||||
// A2b: with AlarmAcknowledge (128, understood since A2b) the row and both grants ride the artifact; Confirm (256) too.
|
||||
root["DataExports"]![0]!["AllowedOperations"] = 5 | 128 | 256;
|
||||
using var newer = DeploymentArtifact.Open(Blob(root));
|
||||
var export = newer.ParseDataExports(NodeA).ShouldHaveSingleItem();
|
||||
export.AllowGalaxyServiceAck.ShouldBeTrue();
|
||||
(export.AllowedOperations & DataOperationSets.Understood).ShouldBe((DataOperations)5);
|
||||
(export.AllowedOperations & DataOperationSets.Understood).ShouldBe((DataOperations)(5 | 128 | 256));
|
||||
// The shelve bit (512) from a newer central is still tolerated and grants nothing.
|
||||
root["DataExports"]![0]!["AllowedOperations"] = 5 | 128 | 512;
|
||||
using var shelve = DeploymentArtifact.Open(Blob(root));
|
||||
(shelve.ParseDataExports(NodeA).ShouldHaveSingleItem().AllowedOperations & DataOperationSets.Understood).ShouldBe((DataOperations)(5 | 128));
|
||||
}
|
||||
|
||||
private static void Read(ParsedDeploymentArtifact parsed, string collection)
|
||||
|
||||
+19
-16
@@ -19,6 +19,9 @@ namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.DataConnections;
|
||||
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "X0")]
|
||||
public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
{
|
||||
// A2b made 128/256 understood: "unknown" here means bits no build defines yet (plus the still-reserved AlarmShelve).
|
||||
private const DataOperations FutureA = (DataOperations)(1 << 11), FutureB = (DataOperations)(1 << 12);
|
||||
|
||||
private static DataConnection Definition(string id, DataOperations operations) => new()
|
||||
{
|
||||
DataConnectionId = id, ClusterId = "owner", Revision = 1, Enabled = true,
|
||||
@@ -34,9 +37,9 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
{
|
||||
var activator = new Activator();
|
||||
await using var runtime = new DataConnectionDeploymentRuntime("node-a", "owner", new Security(), activator, 4);
|
||||
var history = Definition("history", DataOperations.Read | DataOperations.Browse | DataOperations.AlarmConfirm | DataOperations.AlarmShelve);
|
||||
var history = Definition("history", DataOperations.Read | DataOperations.Browse | FutureA | DataOperations.AlarmShelve);
|
||||
var plain = Definition("plain", DataOperations.Read | DataOperations.Subscribe);
|
||||
var future = Definition("future", (DataOperations)(1 << 30) | DataOperations.AlarmAcknowledge); // A2a: 64 is understood
|
||||
var future = Definition("future", (DataOperations)(1 << 30) | FutureB); // A2b: 64/128/256 are understood
|
||||
|
||||
// The pre-X0 runtime threw ArgumentException("Unknown operation.") here for the whole snapshot.
|
||||
Should.NotThrow(() => runtime.Apply(new(1, "artifact-1", [history, plain, future])));
|
||||
@@ -49,18 +52,18 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
|
||||
runtime.DroppedUnknownOperations.ShouldBe(new Dictionary<string, DataOperations>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["history"] = DataOperations.AlarmConfirm | DataOperations.AlarmShelve,
|
||||
["future"] = (DataOperations)(1 << 30) | DataOperations.AlarmAcknowledge,
|
||||
["history"] = FutureA | DataOperations.AlarmShelve,
|
||||
["future"] = (DataOperations)(1 << 30) | FutureB,
|
||||
});
|
||||
runtime.UnknownOperationRowsDropped.ShouldBe(2);
|
||||
// The production reader: the node diagnostics snapshot carries each row's dropped bits.
|
||||
var diagnostics = runtime.CaptureDiagnostics().ToDictionary(x => x.ConnectionId);
|
||||
diagnostics["history"].DroppedUnknownOperations.ShouldBe(DataOperations.AlarmConfirm | DataOperations.AlarmShelve);
|
||||
diagnostics["history"].DroppedUnknownOperations.ShouldBe(FutureA | DataOperations.AlarmShelve);
|
||||
diagnostics["plain"].DroppedUnknownOperations.ShouldBe(DataOperations.None);
|
||||
diagnostics["future"].DroppedUnknownOperations.ShouldBe((DataOperations)(1 << 30) | DataOperations.AlarmAcknowledge);
|
||||
diagnostics["future"].DroppedUnknownOperations.ShouldBe((DataOperations)(1 << 30) | FutureB);
|
||||
diagnostics["plain"].MappingsWithDroppedOperations.ShouldBeNull("no mapping evidence was supplied");
|
||||
// The input rows are not mutated: the drop is the node's reading, not a rewrite of the artifact.
|
||||
history.AllowedOperations.ShouldBe(DataOperations.Read | DataOperations.Browse | DataOperations.AlarmConfirm | DataOperations.AlarmShelve);
|
||||
history.AllowedOperations.ShouldBe(DataOperations.Read | DataOperations.Browse | FutureA | DataOperations.AlarmShelve);
|
||||
activator.Allowlists.Last().Keys.Order(StringComparer.OrdinalIgnoreCase).ShouldBe(["future", "history", "plain"]);
|
||||
}
|
||||
|
||||
@@ -68,7 +71,7 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
public async Task Reapplying_the_same_revision_does_not_recount_and_a_clean_artifact_clears_the_diagnostic()
|
||||
{
|
||||
await using var runtime = new DataConnectionDeploymentRuntime("node-a", "owner", new Security(), new Activator(), 4);
|
||||
var snapshot = new DataConnectionDeploymentSnapshot(1, "artifact-1", [Definition("history", DataOperations.Read | DataOperations.AlarmConfirm)]);
|
||||
var snapshot = new DataConnectionDeploymentSnapshot(1, "artifact-1", [Definition("history", DataOperations.Read | FutureA)]);
|
||||
runtime.Apply(snapshot);
|
||||
runtime.Apply(snapshot);
|
||||
runtime.UnknownOperationRowsDropped.ShouldBe(1);
|
||||
@@ -79,7 +82,7 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
runtime.UnknownOperationRowsDropped.ShouldBe(1);
|
||||
|
||||
// A -> B -> A is an accepted artifact CHANGE each time, so it recounts (documented semantics).
|
||||
runtime.Apply(new(3, "artifact-1", [Definition("history", DataOperations.Read | DataOperations.AlarmConfirm)]));
|
||||
runtime.Apply(new(3, "artifact-1", [Definition("history", DataOperations.Read | FutureA)]));
|
||||
runtime.UnknownOperationRowsDropped.ShouldBe(2);
|
||||
}
|
||||
|
||||
@@ -87,15 +90,15 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
public void Node_side_artifact_parse_accepts_rows_carrying_bits_a_newer_central_authored()
|
||||
{
|
||||
var root = Fixture();
|
||||
root["DataConnections"]![0]!["AllowedOperations"] = (int)(DataOperations.Browse | DataOperations.Read | DataOperations.AlarmConfirm);
|
||||
root["DataExports"]![0]!["AllowedOperations"] = (int)(DataOperations.Browse | DataOperations.Read | DataOperations.AlarmConfirm | DataOperations.AlarmSubscribe);
|
||||
root["RemoteNamespaceMappings"]![0]!["AllowedOperations"] = (int)(DataOperations.Browse | DataOperations.AlarmConfirm);
|
||||
root["DataConnections"]![0]!["AllowedOperations"] = (int)(DataOperations.Browse | DataOperations.Read | FutureA);
|
||||
root["DataExports"]![0]!["AllowedOperations"] = (int)(DataOperations.Browse | DataOperations.Read | FutureA | DataOperations.AlarmSubscribe);
|
||||
root["RemoteNamespaceMappings"]![0]!["AllowedOperations"] = (int)(DataOperations.Browse | FutureA);
|
||||
using var parsed = DeploymentArtifact.Open(Encoding.UTF8.GetBytes(root.ToJsonString()));
|
||||
|
||||
// Pre-X0 each of these threw InvalidDataException through the node-side DataConnectionValidator pass.
|
||||
// Rows come back as authored; each consumer keeps only the bits it understands.
|
||||
parsed.ParseDataConnections("node-a").ShouldHaveSingleItem().AllowedOperations.ShouldBe(
|
||||
DataOperations.Browse | DataOperations.Read | DataOperations.AlarmConfirm);
|
||||
DataOperations.Browse | DataOperations.Read | FutureA);
|
||||
parsed.ParseDataExports("node-b").ShouldHaveSingleItem().DataExportId.ShouldBe("export-a");
|
||||
parsed.ParseRemoteNamespaceMappings("node-a").ShouldHaveSingleItem().RemoteNamespaceMappingId.ShouldBe("mapping-a");
|
||||
}
|
||||
@@ -127,9 +130,9 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
DataExports =
|
||||
[
|
||||
new() { DataExportId = "history", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Raw, RootKind = "Cluster",
|
||||
RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.Browse | DataOperations.Read | DataOperations.AlarmConfirm },
|
||||
RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.Browse | DataOperations.Read | FutureA },
|
||||
new() { DataExportId = "alarms-only", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Uns, RootKind = "Cluster",
|
||||
RootEntityId = "cluster", PrincipalId = "other", AllowedOperations = DataOperations.AlarmConfirm | DataOperations.AlarmAcknowledge }, // A2a: 64 is understood
|
||||
RootEntityId = "cluster", PrincipalId = "other", AllowedOperations = FutureA | FutureB }, // A2b: 64/128/256 are understood
|
||||
],
|
||||
};
|
||||
DataConnectionValidator.Validate(snapshot).ShouldContain(x => x.Code == "DataExportOperationsInvalid", "authoring still rejects reserved bits");
|
||||
@@ -155,7 +158,7 @@ public sealed class GrpcDataUnknownOperationToleranceTests
|
||||
RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.Browse | DataOperations.Read,
|
||||
MaxBatchItems = 100, MaxPageItems = 100, MaxMonitoredItems = 100, MaxStreams = 10 },
|
||||
new() { DataExportId = "future-only", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Uns, RootKind = "Cluster",
|
||||
RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.AlarmConfirm | (DataOperations)(1 << 30),
|
||||
RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = FutureA | (DataOperations)(1 << 30),
|
||||
MaxBatchItems = 1, MaxPageItems = 1, MaxMonitoredItems = 1, MaxStreams = 1 },
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user