v3 B1-WP6: migrate Core + Server test projects to greenfield schema
Fix TESTS only (production already green) so the four in-scope test projects compile + pass under the v3 dark address space: - Core.Abstractions.Tests: drop AllowedNamespaceKinds/NamespaceKindCompatibility from DriverTypeMetadata; rewrite EquipmentTagRefResolver tests to the single-func RawPath-lookup contract (no parseRef/transient cache). - Core.Tests: rewrite EquipmentNodeWalkerTests to EquipmentNamespaceContent(Areas, Lines,Equipment,VirtualTags?,ScriptedAlarms?) — folders + VirtualTags + ScriptedAlarms only; raw-tag variables dark (skipped Batch-4 placeholder). Drop retired Equipment.DriverInstanceId. - Runtime.Tests: rewrite golden corpus + TagConfigCorpusParityTests to the v3 RawPath/RawTagEntry round-trip (byte + TagConfigIntent parity; EquipmentTags dark). Salvage VirtualTag + ScriptedAlarm artifact parity to the new Compose signature. Retire the equipment-tag-materialization parity files (Array/Historize/Alias) and the equipment-device-binding DeviceHost parity to documented skipped placeholders. Skip 34 dark equipment-tag routing/value/alarm/write/discovery actor tests with a shared DarkAddressSpaceReasons constant. Re-key cluster-scoped tests to v3 UNS line->area attribution. - ControlPlane.Tests: ConfigComposer round-trips re-keyed to RawFolder/Device (no Namespaces); tag-config gate resolves driver via Device; deploy-gate collision test re-keyed to UnsEffectiveNameCollision; drop retired BadCrossClusterNamespaceBinding case.
This commit is contained in:
@@ -87,29 +87,27 @@ public sealed class ConfigComposerTests : ControlPlaneActorTestBase
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that <see cref="ConfigComposer.SnapshotAndFlattenAsync"/> serialises a
|
||||
/// <see cref="Device"/>'s <c>HostAddress</c> into the artifact blob and that
|
||||
/// <see cref="DeploymentArtifact.ParseComposition(ReadOnlySpan{byte})"/> decodes it back
|
||||
/// as the equipment's <see cref="ZB.MOM.WW.OtOpcUa.OpcUaServer.EquipmentNode.DeviceHost"/>
|
||||
/// (follow-up E). Guards the real serialize→decode seam: if ConfigComposer's Device
|
||||
/// serialisation ever drifted, DeviceHost would silently become null in production
|
||||
/// (feature E degrades to a warn-skip) while hand-rolled artifact tests stayed green.
|
||||
/// v3: verifies that <see cref="ConfigComposer.SnapshotAndFlattenAsync"/> serialises a
|
||||
/// <see cref="Device"/>'s endpoint into the artifact blob and that
|
||||
/// <see cref="DeploymentArtifact.ParseDriverInstances(ReadOnlySpan{byte})"/> folds the sole
|
||||
/// device's <c>DeviceConfig</c> up into the driver's merged <c>DriverConfig</c> (single-endpoint
|
||||
/// driver). Guards the real serialize→decode seam: if ConfigComposer's Device serialisation ever
|
||||
/// drifted, the endpoint would silently vanish from the driver config in production (the driver
|
||||
/// wouldn't bind) while hand-rolled artifact tests stayed green. (Pre-v3 this rode
|
||||
/// <c>EquipmentNode.DeviceHost</c>; v3 retired that binding — equipment references raw tags via
|
||||
/// UnsTagReference, and the endpoint reaches the driver via the RawPath device merge.)
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task DeviceHost_survives_ConfigComposer_to_ParseComposition_round_trip()
|
||||
public async Task Device_endpoint_survives_ConfigComposer_to_ParseDriverInstances_round_trip()
|
||||
{
|
||||
var f = NewInMemoryDbFactory();
|
||||
await using (var db = f.CreateDbContext())
|
||||
{
|
||||
db.ServerClusters.Add(NewCluster("c1"));
|
||||
db.Namespaces.Add(new Namespace
|
||||
{
|
||||
NamespaceId = "ns-eq", ClusterId = "c1",
|
||||
Kind = NamespaceKind.Equipment, NamespaceUri = "urn:eq",
|
||||
});
|
||||
db.RawFolders.Add(new RawFolder { RawFolderId = "f1", ClusterId = "c1", Name = "Plant" });
|
||||
db.DriverInstances.Add(new DriverInstance
|
||||
{
|
||||
DriverInstanceId = "drv-1", ClusterId = "c1", NamespaceId = "ns-eq",
|
||||
DriverInstanceId = "drv-1", ClusterId = "c1", RawFolderId = "f1",
|
||||
Name = "Focas", DriverType = "Focas", DriverConfig = "{}",
|
||||
});
|
||||
db.Devices.Add(new Device
|
||||
@@ -117,25 +115,23 @@ public sealed class ConfigComposerTests : ControlPlaneActorTestBase
|
||||
DeviceId = "dev-1", DriverInstanceId = "drv-1",
|
||||
Name = "dev-1", DeviceConfig = "{\"HostAddress\":\"10.9.9.9:8193\"}",
|
||||
});
|
||||
db.UnsAreas.Add(new UnsArea { UnsAreaId = "area-1", ClusterId = "c1", Name = "area-1" });
|
||||
db.UnsLines.Add(new UnsLine { UnsLineId = "line-1", UnsAreaId = "area-1", Name = "line-1" });
|
||||
db.Equipment.Add(new Equipment
|
||||
{
|
||||
EquipmentId = "eq-1", DriverInstanceId = "drv-1", DeviceId = "dev-1",
|
||||
UnsLineId = "line-1", Name = "machine-1", MachineCode = "MACHINE_001",
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await using var readDb = f.CreateDbContext();
|
||||
var artifact = await ConfigComposer.SnapshotAndFlattenAsync(readDb);
|
||||
var composition = DeploymentArtifact.ParseComposition(artifact.Blob);
|
||||
var specs = DeploymentArtifact.ParseDriverInstances(artifact.Blob);
|
||||
|
||||
var node = composition.EquipmentNodes.ShouldHaveSingleItem();
|
||||
node.EquipmentId.ShouldBe("eq-1");
|
||||
node.DriverInstanceId.ShouldBe("drv-1");
|
||||
node.DeviceId.ShouldBe("dev-1");
|
||||
node.DeviceHost.ShouldBe("10.9.9.9:8193");
|
||||
var spec = specs.ShouldHaveSingleItem();
|
||||
spec.DriverInstanceId.ShouldBe("drv-1");
|
||||
|
||||
// The sole device's DeviceConfig endpoint is folded up to the top level of the merged DriverConfig.
|
||||
using var doc = System.Text.Json.JsonDocument.Parse(spec.DriverConfig);
|
||||
doc.RootElement.GetProperty("HostAddress").GetString().ShouldBe("10.9.9.9:8193");
|
||||
|
||||
// And the device is still discoverable by its routing-key name in the reconstructed Devices array.
|
||||
var devices = doc.RootElement.GetProperty("Devices").EnumerateArray().ToList();
|
||||
devices.ShouldHaveSingleItem().GetProperty("DeviceName").GetString().ShouldBe("dev-1");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -160,21 +156,16 @@ public sealed class ConfigComposerTests : ControlPlaneActorTestBase
|
||||
await using (var db = f.CreateDbContext())
|
||||
{
|
||||
db.ServerClusters.Add(NewCluster("c1"));
|
||||
db.Namespaces.Add(new Namespace
|
||||
{
|
||||
NamespaceId = "ns-eq", ClusterId = "c1",
|
||||
Kind = NamespaceKind.Equipment, NamespaceUri = "urn:eq",
|
||||
});
|
||||
db.DriverInstances.Add(new DriverInstance
|
||||
{
|
||||
DriverInstanceId = "drv-1", ClusterId = "c1", NamespaceId = "ns-eq",
|
||||
DriverInstanceId = "drv-1", ClusterId = "c1",
|
||||
Name = "Modbus", DriverType = "Modbus", DriverConfig = "{}",
|
||||
ResilienceConfig = resilienceJson,
|
||||
});
|
||||
// A second instance with no override proves the null case rides the same real composer path.
|
||||
db.DriverInstances.Add(new DriverInstance
|
||||
{
|
||||
DriverInstanceId = "drv-2", ClusterId = "c1", NamespaceId = "ns-eq",
|
||||
DriverInstanceId = "drv-2", ClusterId = "c1",
|
||||
Name = "Modbus2", DriverType = "Modbus", DriverConfig = "{}",
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
Reference in New Issue
Block a user