test(grpc-data): A2a — condition stream R tests (priority, overflow reset, hub reset, revocation, deploy deltas, total first, slice cut, UNS no RawPath); delivered-snapshot overflow rule
This commit is contained in:
+33
-2
@@ -11,6 +11,14 @@ namespace ZB.MOM.WW.OtOpcUa.Runtime.DataConnections;
|
||||
/// Production is pull-based (<see cref="ConditionItemStream"/>): an item produces only while the queue has room, so a slow
|
||||
/// consumer back-pressures into the hub, whose eviction resets the item to a fresh snapshot.
|
||||
/// </summary>
|
||||
internal static class ConditionTestAssertions
|
||||
{
|
||||
internal static void ShouldBeTrueForTests(this bool value)
|
||||
{
|
||||
if (!value) throw new InvalidOperationException("Test probe could not be queued.");
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed partial class DataSubscriptionSession
|
||||
{
|
||||
private sealed class ConditionItem(string clientItemId, DataItemHandle handle, ConditionItemAuthority authority,
|
||||
@@ -152,6 +160,7 @@ internal sealed partial class DataSubscriptionSession
|
||||
chunk.IsSnapshot, chunk.Total, chunk.Items, chunk.SnapshotComplete),
|
||||
() => Volatile.Read(ref _closed) == 0 && Volatile.Read(ref _closing) == 0
|
||||
&& _services.CanUseSubscription(_context, _target, serving) && IsConditionItemCurrent(item) && item.Authority.CanPublish(),
|
||||
commit: () => { if (chunk.EndsSnapshot) item.Stream.SnapshotDelivered(chunk.Snapshot); return true; },
|
||||
obsolete: () => Volatile.Read(ref _closing) != 0 || !IsConditionItemCurrent(item));
|
||||
}
|
||||
|
||||
@@ -161,8 +170,10 @@ internal sealed partial class DataSubscriptionSession
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The next delivery by priority: a queued control or ack first, then a condition frame, then the queued value. Null
|
||||
/// when the stream's queues are completed and drained.
|
||||
/// The next delivery by priority: a control or ack at the head of the v1 queue first, then a condition frame, then the
|
||||
/// v1 queue in FIFO order (a v1 control never overtakes a value queued before it: snapshot begin/end ordering depends
|
||||
/// on that). So conditions overtake queued values, and never a control or ack that is next. Null when the stream's
|
||||
/// queues are completed and drained.
|
||||
/// </summary>
|
||||
private async ValueTask<PendingDelivery?> NextPendingAsync(CancellationToken token)
|
||||
{
|
||||
@@ -195,6 +206,26 @@ internal sealed partial class DataSubscriptionSession
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Test seam: the stream has processed its Open.</summary>
|
||||
internal bool IsOpenForTests => Volatile.Read(ref _handles) is not null;
|
||||
|
||||
/// <summary>
|
||||
/// Test seam (stream priority): queues an empty value frame and a heartbeat control on the v1 queue (control first
|
||||
/// when <paramref name="controlFirst"/>), then a condition frame.
|
||||
/// </summary>
|
||||
internal async Task EnqueuePriorityProbesForTests(DataItemHandle conditionHandle, bool controlFirst)
|
||||
{
|
||||
var serving = _serving!;
|
||||
PendingDelivery Value() => new(sequence => new DataSubscriptionValues(_subscriptionId!, _epoch, sequence, false, []),
|
||||
() => true, isValue: true);
|
||||
PendingDelivery Control() => new(sequence => new DataSubscriptionControl(_subscriptionId!, _epoch, sequence,
|
||||
DataStreamControlKind.Heartbeat, [], serving.CatalogEpoch, serving.AuthorityEpoch, null), () => true);
|
||||
await EnqueueAsync(controlFirst ? Control() : Value()).ConfigureAwait(false);
|
||||
await EnqueueAsync(controlFirst ? Value() : Control()).ConfigureAwait(false);
|
||||
ConditionOutbound.Writer.TryWrite(new PendingDelivery(sequence => new DataSubscriptionConditions(_subscriptionId!, _epoch,
|
||||
sequence, conditionHandle, false, null, [], false), () => true)).ShouldBeTrueForTests();
|
||||
}
|
||||
|
||||
/// <summary>Called from the worker's teardown: completes and drains the condition queue, releases condition items.</summary>
|
||||
private void TearDownConditions()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user