Subscription tests: wait for all initial values after a transfer

InternalTransferSubscriptionAsync waited until each dynamic target
subscription had received at least one notification, then asserted at
least MonitoredItemCount when sendInitialValues is set. The initial
values of a transferred subscription can arrive in several publish
responses, so the wait could release after a partial batch
(TransferSubscriptionAsync(True,True,True) saw 9 of 10 on Linux and 1 of
10 on net48 in PR #4916 CI). Wait for the same count the assertion checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Roman Ettlinger
2026-10-27 08:37:50 +01:00
co-authored by Claude Opus 5.5
parent 53617e4900
commit d3506f2b75
@@ -451,11 +451,15 @@ namespace Opc.Ua.Subscriptions.Classic.Tests
TestContext.Out
.WriteLine("TargetSession is now SessionId={0}", targetSession.SessionId);
// The initial values of a transferred subscription can span several
// publish responses, so wait for the full count asserted below, not
// just the first notification.
await TestPolling.WaitUntilAsync(
() => staticTargetNotifications.Count >= expectedStaticBatchCount &&
Volatile.Read(ref targetKeepAliveCount) > 0 &&
Enumerable.Range(1, kTestSubscriptions - 1).All(index =>
Volatile.Read(ref targetSubscriptionCounters[index]) > 0 &&
Volatile.Read(ref targetSubscriptionCounters[index]) >=
(sendInitialValues ? (int)transferSubscriptions[index].MonitoredItemCount : 1) &&
Volatile.Read(ref targetSubscriptionFastDataCounters[index]) > 0),
timeoutMessage: "The target did not deliver expected notifications and a keepalive.")
.ConfigureAwait(false);