Fix flaky data channel budget assertions

Check per-flow DATA reservations instead of the shared message total, which also counts concurrently admitted control frames. Dispose shared Core contexts before asserting that close-control reservations have drained after PubSub stops.
This commit is contained in:
Marc
2026-10-19 13:25:41 +02:00
parent 0de303cad6
commit 690ea3dddd
2 changed files with 8 additions and 1 deletions
@@ -181,7 +181,8 @@ namespace Opc.Ua.Core.DataChannels.Tests.Runtime
{
Assert.That(pending.IsCompleted, Is.False);
Assert.That(waiting.Local.StateData.LastDataId, Is.Zero);
Assert.That(budget.Usage.Messages, Is.EqualTo(heldCount));
Assert.That(occupied.Local.StateData.SendMessages, Is.EqualTo(heldCount));
Assert.That(waiting.Local.StateData.SendMessages, Is.Zero);
first.InitiatorCarrier.BeforeRelease.TrySetResult(true);
Assert.That(await Task.WhenAll(held).WaitAsync(TimeSpan.FromSeconds(5)).ConfigureAwait(false),
Is.All.EqualTo(DataChannelResult.Good));
@@ -431,6 +431,12 @@ namespace Opc.Ua.PubSub.Tests.Transports.DataChannels
{
Assert.That(core.LeftBudget.Usage.Flows, Is.Zero);
Assert.That(core.RightBudget.Usage.Flows, Is.Zero);
});
// Shared Core contexts can still own close-control reservations after the PubSub flows stop.
await core.Left.DisposeAsync().ConfigureAwait(false);
await core.Right.DisposeAsync().ConfigureAwait(false);
Assert.Multiple(() =>
{
Assert.That(core.LeftBudget.Usage.Messages, Is.Zero);
Assert.That(core.RightBudget.Usage.Messages, Is.Zero);
});