test(grpc-data): A2b F — method bits authorable, shelve reserved, Galaxy opt-in rule, deploy-gate capacity warning

This commit is contained in:
Joseph Doherty
2026-11-24 13:41:51 -05:00
parent 9444044540
commit 8d5077c07d
2 changed files with 24 additions and 10 deletions
@@ -25,10 +25,21 @@ public sealed class GrpcDataConditionConfigurationTests
[Theory]
[InlineData(128)]
[InlineData(256)]
[InlineData(512)]
public void The_method_bits_stay_unauthorable_until_A2b(int bit)
public void A2b_the_acknowledge_and_confirm_bits_are_authorable(int bit)
{
var errors = DataConnectionValidator.Validate(GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms | (DataOperations)bit));
errors.ShouldNotContain(x => x.Code.EndsWith("OperationsInvalid", StringComparison.Ordinal));
// A mapping may not take a method bit its connection does not grant (mapping ⊆ connection, understood bits).
var wider = GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms);
wider.RemoteNamespaceMappings[0].AllowedOperations = Alarms | (DataOperations)bit;
DataConnectionValidator.Validate(wider).ShouldContain(x => x.Code == "DataMappingOperationsInvalid" && x.Context == "mapping");
DataConnectionValidator.ValidateDeployed(wider).ShouldContain(x => x.Code == "DataMappingOperationsInvalid");
}
[Fact]
public void The_shelve_bit_stays_unauthorable()
{
var errors = DataConnectionValidator.Validate(GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms | DataOperations.AlarmShelve));
errors.ShouldContain(x => x.Code == "DataConnectionOperationsInvalid");
errors.ShouldContain(x => x.Code == "DataExportOperationsInvalid");
errors.ShouldContain(x => x.Code == "DataMappingOperationsInvalid");
@@ -102,20 +113,21 @@ public sealed class GrpcDataConditionConfigurationTests
}
[Fact]
public void AllowGalaxyServiceAck_requires_AlarmAcknowledge_so_it_cannot_be_authored_before_A2b()
public void AllowGalaxyServiceAck_is_valid_only_with_AlarmAcknowledge()
{
var draft = GrpcDataReservedOperationAuthoringTests.Snapshot(Alarms);
DataConnectionValidator.Validate(draft).ShouldNotContain(x => x.Code == "DataExportGalaxyAckInvalid");
draft.DataExports[0].AllowGalaxyServiceAck = true;
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataExportGalaxyAckInvalid" && x.Context == "export");
DataConnectionValidator.ValidateDeployed(draft).ShouldContain(x => x.Code == "DataExportGalaxyAckInvalid" && x.Context == "export");
// With the acknowledge grant: authoring still refuses the (A2b) bit itself, but not the flag; a deployed row from a
// newer central carrying both is tolerated (the bit is ignored, the flag is inert).
// A2b: with the acknowledge grant both the bit and the flag author and deploy cleanly.
draft.DataExports[0].AllowedOperations = Alarms | DataOperations.AlarmAcknowledge;
var authored = DataConnectionValidator.Validate(draft);
authored.ShouldContain(x => x.Code == "DataExportOperationsInvalid");
authored.ShouldNotContain(x => x.Code == "DataExportGalaxyAckInvalid");
authored.ShouldNotContain(x => x.Code == "DataExportOperationsInvalid" || x.Code == "DataExportGalaxyAckInvalid");
DataConnectionValidator.ValidateDeployed(draft).ShouldNotContain(x => x.Code == "DataExportOperationsInvalid" || x.Code == "DataExportGalaxyAckInvalid");
// Confirm alone does not qualify the opt-in.
draft.DataExports[0].AllowedOperations = Alarms | DataOperations.AlarmConfirm;
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataExportGalaxyAckInvalid");
}
[Fact]
@@ -145,6 +157,8 @@ public sealed class GrpcDataConditionConfigurationTests
DataConnectionValidator.ConditionCapacityWarnings(draft, 200_000).ShouldBeEmpty();
DataConnectionValidator.ConditionCapacityWarnings(draft, 49_000).Count.ShouldBe(1, "node-b at exactly the cap is not over it");
DataConnectionValidator.ConditionCapacityWarnings(draft, 48_999).Count.ShouldBe(2);
// A2b: the deploy gate logs the same rule, non-blocking (AdminOperationsActor.StartDeployment).
DataConnectionValidator.DeployWarnings(draft).ShouldHaveSingleItem().ShouldStartWith("[DataConditionCapacityWarning] Consumer node node-a");
}
[Fact]
@@ -13,9 +13,9 @@ namespace ZB.MOM.WW.OtOpcUa.Configuration.Tests.DataConnections;
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "X0")]
public sealed class GrpcDataReservedOperationAuthoringTests
{
// H2 implemented 32 (HistoryRead) and A2a 64 (AlarmSubscribe): authoring accepts them (GrpcDataHistoryConfigurationTests,
// GrpcDataConditionConfigurationTests). A2b takes the method bits.
public static TheoryData<int> ReservedBits => new(128, 256, 512);
// H2 implemented 32 (HistoryRead), A2a 64 (AlarmSubscribe), A2b 128/256 (AlarmAcknowledge/AlarmConfirm): authoring accepts
// them (GrpcDataHistoryConfigurationTests, GrpcDataConditionConfigurationTests). 512 (AlarmShelve) stays reserved.
public static TheoryData<int> ReservedBits => new(512);
[Theory]
[MemberData(nameof(ReservedBits))]