test(grpc-data): A2a — rig --conditions overlay (AlarmSubscribe exports + ScalarHigh scripted alarm), probe conditions scenario, conditions_smoke.py; X0/H2 tests move the 'future' bit off 64
This commit is contained in:
@@ -29,6 +29,9 @@ const DataOperations operations = DataOperations.Browse | DataOperations.Metadat
|
||||
// exports gain HistoryRead, and a second principal's export lacks it. Unset ⇒ the v1 fixture, unchanged.
|
||||
var history = Environment.GetEnvironmentVariable("GRPC_DATA_HISTORY") == "1";
|
||||
var grantedOperations = history ? operations | DataOperations.HistoryRead : operations;
|
||||
// A2a smoke profile (opt-in, `rig.py up --conditions`): SOURCE exports gain AlarmSubscribe and the SOURCE equipment gets
|
||||
// one scripted alarm, ScalarHigh (scalar > 100), so a condition stream sees a snapshot and a delta. Unset ⇒ v1 fixture.
|
||||
var conditions = Environment.GetEnvironmentVariable("GRPC_DATA_CONDITIONS") == "1";
|
||||
try
|
||||
{
|
||||
if (args.Length == 0) return 2;
|
||||
@@ -372,6 +375,14 @@ try
|
||||
db.Equipment.Add(new() { EquipmentRowId = Guid.NewGuid(), EquipmentId = equipment, EquipmentUuid = uuid, UnsLineId = "source-line", Name = "plc", MachineCode = "fixture-plc" });
|
||||
foreach (var name in new[] { "counter", "scalar", "array0", "array1", "array2", "vector", "text" }.Concat(history ? ["flt"] : []))
|
||||
db.UnsTagReferences.Add(new() { UnsTagReferenceRowId = Guid.NewGuid(), UnsTagReferenceId = "ref-" + name, EquipmentId = equipment, TagId = "source-" + name });
|
||||
if (conditions)
|
||||
{
|
||||
const string predicate = "return Convert.ToInt32(ctx.GetTag(\"modbus/plc/scalar\").Value) > 100;";
|
||||
db.Scripts.Add(new() { ScriptRowId = Guid.NewGuid(), ScriptId = "source-scalar-high", Name = "scalar-high", SourceCode = predicate,
|
||||
SourceHash = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(predicate))) });
|
||||
db.ScriptedAlarms.Add(new() { ScriptedAlarmRowId = Guid.NewGuid(), ScriptedAlarmId = "source-scalar-high", EquipmentId = equipment,
|
||||
Name = "ScalarHigh", AlarmType = "AlarmCondition", MessageTemplate = "scalar high", PredicateScriptId = "source-scalar-high" });
|
||||
}
|
||||
db.NodeAcls.Add(new() { NodeAclRowId = Guid.NewGuid(), NodeAclId = "source-peer", ClusterId = "SOURCE", Principal = "fixture-consumer",
|
||||
ScopeKind = NodeAclScopeKind.Cluster, PermissionFlags = NodePermissions.Admin });
|
||||
db.DataConnections.Add(new() { DataConnectionRowId = Guid.NewGuid(), DataConnectionId = "consumer-source", ClusterId = "CONSUMER", Enabled = true,
|
||||
@@ -385,7 +396,8 @@ try
|
||||
var rootKind = realm == DataRealm.Raw ? "RawDevice" : "Equipment";
|
||||
var entity = realm == DataRealm.Raw ? "source-device" : equipment;
|
||||
db.DataExports.Add(new() { DataExportRowId = Guid.NewGuid(), DataExportId = "export-" + name, ClusterId = "SOURCE", Enabled = true,
|
||||
Realm = realm, RootKind = rootKind, RootEntityId = entity, PrincipalId = "fixture-consumer", AllowedOperations = grantedOperations });
|
||||
Realm = realm, RootKind = rootKind, RootEntityId = entity, PrincipalId = "fixture-consumer",
|
||||
AllowedOperations = grantedOperations | (conditions ? DataOperations.AlarmSubscribe : DataOperations.None) });
|
||||
if (history)
|
||||
db.DataExports.Add(new() { DataExportRowId = Guid.NewGuid(), DataExportId = "export-" + name + "-nohistory", ClusterId = "SOURCE", Enabled = true,
|
||||
Realm = realm, RootKind = rootKind, RootEntityId = entity, PrincipalId = "fixture-nohistory", AllowedOperations = operations });
|
||||
|
||||
Reference in New Issue
Block a user