test: validate grpc data connections with local docker and opcua cli

This commit is contained in:
Joseph Doherty
2026-11-17 22:01:26 -05:00
parent 1df29a3124
commit 29fec57fac
194 changed files with 23327 additions and 740 deletions
@@ -4,6 +4,16 @@ using ZB.MOM.WW.OtOpcUa.Runtime.Drivers;
namespace ZB.MOM.WW.OtOpcUa.Runtime.DataConnections;
internal interface IObsoleteProjectedSample { bool CanDropExpiredPredecessor { get; } }
internal static class ProjectedEvidenceRetirement
{
internal static bool CanDrop(IProjectedSamplePublicationProof proof)
{
try { return !proof.IsValid && proof.IsSourceValid && proof is IObsoleteProjectedSample { CanDropExpiredPredecessor: true }; }
catch (Exception) { return false; }
}
}
/// <summary>Owns bounded imported-value messages through the actual SDK apply, with captured route ownership.</summary>
public sealed class ActorProjectedValuePublisher : IProjectedValuePublisher, IDisposable
{
@@ -128,7 +138,14 @@ public sealed class ActorProjectedValuePublisher : IProjectedValuePublisher, IDi
}
}
public TimeProvider Clock => source.Clock;
public void Invalidate() { try { source.Invalidate(); } finally { owner.RetireWitness(binding, identity); } }
public void Invalidate()
{
// An expired sample can remain queued across a compatible authority
// handoff. Discard that evidence without retiring the independently live
// logical source which may already own a fresh successor baseline.
if (ProjectedEvidenceRetirement.CanDrop(source) && IsSourceValid) return;
try { source.Invalidate(); } finally { owner.RetireWitness(binding, identity); }
}
}
private bool OwnsIdentity(Binding binding, object identity)
{
@@ -159,6 +176,7 @@ public sealed class ActorProjectedValuePublisher : IProjectedValuePublisher, IDi
{
foreach (var update in updates)
{
if (ProjectedEvidenceRetirement.CanDrop(update.SourceProof) && IsCurrent(update.Route)) continue;
try { update.SourceProof.Invalidate(); } catch (Exception) { }
Retire(update.Route);
}
@@ -187,7 +205,7 @@ public sealed class ActorProjectedValuePublisher : IProjectedValuePublisher, IDi
var update = captured[i];
update.OriginAgeBounds.Validate();
if (!ReferenceEquals(update.SourceProof.Clock, _clock) || !update.SourceProof.IsValid
|| _clock.GetElapsedTime(update.ReceivedTimestamp) < TimeSpan.Zero || !Authorized(update.Route)) return Refused();
|| update.SourceVersion is <= 0 || _clock.GetElapsedTime(update.ReceivedTimestamp) < TimeSpan.Zero || !Authorized(update.Route)) return Refused();
charge = checked(charge + 512 + OwnedDataSample.Estimate(update.Snapshot.Value));
}
var admitted = false;
@@ -212,7 +230,7 @@ public sealed class ActorProjectedValuePublisher : IProjectedValuePublisher, IDi
var writes = captured.Select((update, i) => new ProjectedValueWrite(update.Route.Realm, update.Route.LocalIdentifier,
update.Route.ProjectionGeneration, update.Route.Serving,
update.Snapshot with { Value = OwnedDataSample.CopyLegacy(update.Snapshot.Value) }, update.OriginAgeBounds,
update.ReceivedTimestamp, WitnessFor(bindings[i], update), update.IsCompleteSnapshot)).ToArray();
update.ReceivedTimestamp, WitnessFor(bindings[i], update), update.IsCompleteSnapshot, update.SourceVersion)).ToArray();
batch = new(writes, captured.Select(update => update.Route).ToArray(), Complete, ForwardToMux);
lock (_sync)
{