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:
Joseph Doherty
2026-07-15 21:26:00 -04:00
parent 604928b29d
commit 329144b1aa
26 changed files with 425 additions and 1445 deletions
@@ -175,13 +175,14 @@ public sealed class AdminOperationsActorTests : ControlPlaneActorTestBase
db.ConfigEdits.Single().EntityType.ShouldBe("Deployment");
}
/// <summary>Verifies the full DraftValidator gate (reject on ANY error): a Tag↔VirtualTag
/// NodeId collision in the live config rejects the deploy (422-mapped
/// <see cref="StartDeploymentOutcome.Rejected"/>) before any coordinator dispatch — and inserts
/// no Deployment row. The colliding equipment uses a canonical EquipmentId so the rejection is
/// <summary>Verifies the full DraftValidator gate (reject on ANY error): a v3 UNS effective-name
/// collision — a UnsTagReference (surfacing a raw Tag under an equipment) and a VirtualTag sharing the
/// same effective leaf name in that equipment's UNS NodeId space — rejects the deploy (422-mapped
/// <see cref="StartDeploymentOutcome.Rejected"/>) before any coordinator dispatch, inserting no
/// Deployment row. The colliding equipment uses a canonical EquipmentId so the rejection is
/// attributable to the collision rule, not to EquipmentIdNotDerived.</summary>
[Fact]
public void StartDeployment_rejects_on_Tag_VirtualTag_NodeId_collision()
public void StartDeployment_rejects_on_UNS_effective_name_collision()
{
var uuid = Guid.NewGuid();
var equipmentId = Configuration.Validation.DraftValidator.DeriveEquipmentId(uuid);
@@ -194,20 +195,32 @@ public sealed class AdminOperationsActorTests : ControlPlaneActorTestBase
EquipmentUuid = uuid,
EquipmentId = equipmentId,
Name = "eq",
DriverInstanceId = "d",
UnsLineId = "line-a",
MachineCode = "m",
});
// v3: a raw Tag binds to a Device; it reaches the equipment's UNS space via a UnsTagReference.
db.DriverInstances.Add(new Configuration.Entities.DriverInstance
{
DriverInstanceId = "d", ClusterId = "", Name = "drv", DriverType = "Modbus", DriverConfig = "{}",
});
db.Devices.Add(new Configuration.Entities.Device
{
DeviceId = "dev", DriverInstanceId = "d", Name = "dev", DeviceConfig = "{}",
});
db.Tags.Add(new Configuration.Entities.Tag
{
TagId = "tag-speed",
DriverInstanceId = "d",
EquipmentId = equipmentId,
DeviceId = "dev",
Name = "speed",
DataType = "Float",
AccessLevel = TagAccessLevel.Read,
TagConfig = "{}",
});
db.UnsTagReferences.Add(new Configuration.Entities.UnsTagReference
{
UnsTagReferenceId = "ref-speed", EquipmentId = equipmentId, TagId = "tag-speed",
});
// A VirtualTag whose Name collides with the reference's effective name "speed".
db.VirtualTags.Add(new Configuration.Entities.VirtualTag
{
VirtualTagId = "vtag-speed",
@@ -228,8 +241,8 @@ public sealed class AdminOperationsActorTests : ControlPlaneActorTestBase
var reply = ExpectMsg<StartDeploymentResult>(TimeSpan.FromSeconds(3));
reply.Outcome.ShouldBe(StartDeploymentOutcome.Rejected);
reply.Message.ShouldNotBeNull();
reply.Message.ShouldContain("EquipmentSignalNameCollision"); // the rule's error code
reply.Message.ShouldContain("collide"); // the rule's message text
reply.Message.ShouldContain("UnsEffectiveNameCollision"); // the v3 rule's error code
reply.Message.ShouldContain("collide"); // the rule's message text
using var verify = dbFactory.CreateDbContext();
verify.Deployments.Count().ShouldBe(0);
@@ -251,7 +264,6 @@ public sealed class AdminOperationsActorTests : ControlPlaneActorTestBase
EquipmentUuid = Guid.NewGuid(),
EquipmentId = "EQ-operator-typed", // NOT derived from the UUID
Name = "rinser-01",
DriverInstanceId = "d",
UnsLineId = "line-a",
MachineCode = "m",
});
@@ -273,53 +285,11 @@ public sealed class AdminOperationsActorTests : ControlPlaneActorTestBase
verify.Deployments.Count().ShouldBe(0);
}
/// <summary>Verifies that a DriverInstance whose NamespaceId lives in a different cluster
/// triggers <c>BadCrossClusterNamespaceBinding</c> and routes to the Rejected branch through
/// the actor — no coordinator dispatch, no Deployment row.
/// Seeded: Namespace in cluster "MAIN" + DriverInstance in cluster "SITE-A" referencing that
/// namespace. NamespaceKind.Equipment + DriverType "Modbus" satisfies the compat rule so
/// only the cross-cluster rule fires.</summary>
[Fact]
public void StartDeployment_rejects_on_cross_cluster_namespace_binding()
{
const string nsId = "ns-main-equipment";
var dbFactory = NewInMemoryDbFactory();
using (var db = dbFactory.CreateDbContext())
{
db.Namespaces.Add(new Configuration.Entities.Namespace
{
NamespaceId = nsId,
ClusterId = "MAIN",
Kind = Configuration.Enums.NamespaceKind.Equipment,
NamespaceUri = "urn:zb:main:equipment",
});
db.DriverInstances.Add(new Configuration.Entities.DriverInstance
{
DriverInstanceId = "drv-site-a-01",
ClusterId = "SITE-A",
NamespaceId = nsId, // cross-cluster: drv is SITE-A, ns is MAIN
Name = "site-a-modbus",
DriverType = "Modbus", // compatible with Equipment ns — no compat error
DriverConfig = "{}",
});
db.SaveChanges();
}
var coordinator = CreateTestProbe("coord");
var actor = Sys.ActorOf(AdminOperationsActor.Props(dbFactory, coordinator.Ref, Enumerable.Empty<IDriverProbe>()));
actor.Tell(new StartDeployment("joe", CorrelationId.NewId()));
coordinator.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
var reply = ExpectMsg<StartDeploymentResult>(TimeSpan.FromSeconds(3));
reply.Outcome.ShouldBe(StartDeploymentOutcome.Rejected);
reply.Message.ShouldNotBeNull();
reply.Message.ShouldContain("BadCrossClusterNamespaceBinding");
using var verify = dbFactory.CreateDbContext();
verify.Deployments.Count().ShouldBe(0);
}
// RETIRED (v3): the Namespace entity and its cluster-binding rule (BadCrossClusterNamespaceBinding)
// are deleted — the two OPC UA namespaces (Raw/UNS) are implicit and driver instances no longer bind a
// Namespace. There is no v3 analog for a cross-cluster namespace binding, so this deploy-gate case is
// dropped (per the v3 schema migration). Cluster scoping is now exercised via the UNS line→area→cluster
// attribution covered in DeploymentArtifactTests.
/// <summary>Verifies the warn-only compile-cost advisory: seeding N distinct non-passthrough
/// (genuinely-compiled) Script rows yields an <see cref="StartDeploymentOutcome.Accepted"/>